nginx+php+多个域名,nginx如何配置多个域名去掉index.php?

本文介绍了如何在Nginx配置中分别去掉mobile、app、restserver、apph5等目录下的index.php。通过使用if条件判断和rewrite规则,可以实现对不同目录URL路径中index.php的移除,确保每个目录内容的正确访问。
摘要由CSDN通过智能技术生成

nginx如果配置去掉index.php

location /{

if ($request_filename !~ (system|images|robots\.txt|index\.php.*) ) {

rewrite ^/(.*)$ /mobile/index.php/$1 last;

}

}

这样是可以的

因为在网站根目录下 放了好几个目录 每个目录是不同的内容

我想分别都去掉这几个 mobile app restserver apph5这几个的url路径的index.php

改怎么配置啊

这里有

www----根目录

---mobile---

---app---

---restserver---

---apph5---

回复内容:

nginx如果配置去掉index.php

location /{

if ($request_filename !~ (system|images|robots\.txt|index\.php.*) ) {

rewrite ^/(.*)$ /mobile/index.php/$1 last;

}

}

这样是可以的

因为在网站根目录下 放了好几个目录 每个目录是不同的内容

我想分别都去掉这几个 mobile app restserver apph5这几个的url路径的index.php

改怎么配置啊

这里有

www----根目录

---mobile---

---app---

---restserver---

---apph5---

if (!-e $request_filename) {

rewrite ^/mobile/(.*)$ /mobile/index.php/$1 last;

rewrite ^/app/(.*)$ /app/index.php/$1 last;

rewrite ^/restserver/(.*)$ /restserver/index.php/$1 last;

rewrite ^/apph5/(.*)$ /apph5/index.php/$1 last;

}

if (!-e $request_filename) {

rewrite ^(.*)$ /index.php?s=$1 last;

break;

}

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:php中文网

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值