php 重定向到其他目录,Nginx将所有请求从子目录重定向到另一个子目录根目录

我对Nginx还不熟悉,所以请耐心等待。在

我试图将所有请求从一个子目录(store)重定向到另一个子目录(trade)的根目录。请看下面我的进度。目标子目录(trade)中的站点是一个magento站点,因此这是当前大多数规则的用途

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 the PHP scripts to 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;

}

}

我用于重定向的部分如下:

location ~ /store {

rewrite /trade permanent;

}

这对example.com/store但不是示例/存储/索引.php或任何其他带参数的uri。我有一种感觉,底部的php文件部分覆盖了处理过程。这就是为什么我把~放在商店前面作为文件here声明将首先处理此项。还是继续处理?在

我读过关于嵌套一个php规则的文章,但是我尝试过没有用

我将非常感谢你的帮助

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值