![](/img/trans.png)
[英]How to access directory's index.php without a trailing slash AND not get 301 redirect
[英]How to access directory's index.php without a trailing slash AND not get 301 redirect (NGinx)
我最终获得了该示例Apache配置,并使用配置重写服务将配置转换为Nginx格式。 它产生了一个大部分有效的解决方案,但是有点破损。 它按预期的那样访问URL,但是当访问/ api /中不存在的文件或目录时,它会中断访问资源并导致/api/index.php被转储为下载。
我尝试使用配置来产生以下配置,该配置使用提供给整个服务器的html 404消息。
location /api {
if (-e $request_filename){
rewrite ^/(.*[^/])$ /$1/;
}
}
我的文件结构是:
/api/index.php
/api/hotbits/index.php
/api/cryptography/index.php
使用新的config选项,它将转换为以下功能URL:
/api
/api/
/api/hotbits
/api/hotbits/
/api/cryptography
/api/cryptography/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.