Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Apache .htaccess
RedirectMatch 301 ^/wp-content/uploads/(.*) http://livewebsite.com/wp-content/uploads/$1
# Nginx
location ~ ^/wp-content/uploads/(.*) {
rewrite ^/wp-content/uploads/(.*)$ http://livewebsite.com/wp-content/uploads/$1 redirect;
}
@mgratch

This comment has been minimized.

Copy link

mgratch commented Apr 26, 2019

Nginx Notes

Nginx tries to apply blocks from the top to the bottom, therefore this needs to go at the top of the server block directly underneath:

server {
    listen 443 ssl http2;
    server name domain.test www.domain.test *.domain.test;
    root /;
    charset utf-8;
@mgratch

This comment has been minimized.

Copy link

mgratch commented Apr 26, 2019

Using Browsersync with Valet and Nginx

In order to use Browsersync with Valet & Nginx you will need to add proxy_* settings to your root location block. There should already be a rewrite ^ there pointing to server.php. The Proxy settings will go underneath the rewrite setting. Like so:

    location / {
        rewrite ^ /home/username/.config/composer/vendor/valeryan/valet-wsl/server.php last;
        proxy_pass          https://localhost:3000;
        proxy_set_header    Host             $host;
        proxy_set_header    X-Real-IP        $remote_addr;
        proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header    X-Client-Verify  SUCCESS;
        proxy_set_header    X-Client-DN      $ssl_client_s_dn;
        proxy_set_header    X-SSL-Subject    $ssl_client_s_dn;
        proxy_set_header    X-SSL-Issuer     $ssl_client_i_dn;
        proxy_read_timeout 1800;
        proxy_connect_timeout 1800;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.