php - Nginx redirect all requests from subdirectory to another subdirectory root -
i'm quite new nginx please bear me.
i'm trying redirect requests 1 subdirectory (store) root of subdirectory (trade). see progress below. site in target subdirectory (trade) magento site of current rules for.
server { server_name example.com *.example.com; root /usr/share/nginx/html/example.com/public_html; index index.php index.html index.htm; access_log /var/log/nginx/example.access.log; error_log /var/log/nginx/example.error.log; location / { try_files $uri $uri/ /index.html; } location /trade/ { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location ~ /store { rewrite /trade permanent; } location ~ ^/trade/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; } location /trade/var/export/ { internal; } location /. { return 404; } location @handler { rewrite / /trade/index.php; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass php scripts fastcgi server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } }
the section using redirect following:
location ~ /store { rewrite /trade permanent; }
this works example.com/store not example/store/index.php or other uri args. have feeling php file section @ bottom overriding processing. why have put ~ in front of store location documentation here states processed first. processing stop or continue on?
i have read nesting php rule have tried no avail.
i appreciate help.
ok try this
location ^~ /store(.*) { return 301 $scheme://$http_host/trade$1$is_args$query_string; }
trying avoid hardcoded stuff as possible , using return because it's prefered on permanent rewrites
Comments
Post a Comment