脚本宝典收集整理的这篇文章主要介绍了php – apache .htaccess到nginx重写规则,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的Apache .htaccess中得到了以下内容:
RewrITeEngine On # always run through the indexfile rewriterule .$index.PHP # don't let PEople peek into directories without an index file Options -indexes
当我在Nginx服务器上放置.htaccess时,服务器会删除该文件.
我需要在什么样的文件中放置.htaccess数据(请注明名称和后缀)以及如何为Nginx重写它以及在哪里放置文件?
我希望所有子目录文件都通过我的index.PHP文件,所以我可以包含我的index.PHP文件中的特定文件…
我尝试过类似的东西:
# Nginx configuration autoindex off; location / { rewrite .$/index.PHP; }
但它不起作用.该目录看起来像:
── root ├── folder1 │ └── folder2 │ └── file.PHP └── index.PHP
所以,如果我要求root / folder1 / folder2 / file.PHP我希望服务器加载root / index.PHP,因为我仍然有服务器url请求,
我可以在index.PHP中包含root / folder1 / folder2 / file.PHP
这一切都适用于我的apache安装,但不适用于Nginx服务器.
请帮我.
#
编辑:
事实证明,Nginx.conf文件必须位于根文件夹之上,并且只有在您可以访问根文件夹上方的文件夹时才能访问.像服务器管理员访问是必要的.
# Nginx configuration autoindex off; location / { rewrite .* /index.PHP last; }
以上是脚本宝典为你收集整理的php – apache .htaccess到nginx重写规则全部内容,希望文章能够帮你解决php – apache .htaccess到nginx重写规则所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。