Med*_*a86 5 php apache .htaccess mod-rewrite nginx
我需要从apache更改为Nginx,但不能.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
Run Code Online (Sandbox Code Playgroud)
当我.htaccess
在Nginx服务器上放置文件时,服务器会删除该文件.在什么样的文件中我需要放置.htaccess
数据(请注明名称和后缀)以及如何为Nginx重写它以及在哪里放置文件?
我希望所有子目录文件都通过我的index.php
文件,所以我可以包含我的index.php
文件中的特定文件...
我尝试过类似的东西:
# nginx configuration
autoindex off;
location / {
rewrite .$ /index.php;
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.该目录看起来像:
?? root
??? folder1
? ??? folder2
? ??? file.php
??? index.php
Run Code Online (Sandbox Code Playgroud)
所以,如果我要求root/folder1/folder2/file.php
我希望服务器加载,root/index.php
因为我仍然有服务器URL请求,我可以包括root/folder1/folder2/file.php
从我的index.php
这一切都适用于我的apache安装,但不适用于Nginx服务器.请帮我.
#编辑:原来nginx.conf
文件必须在根文件夹之上,只有在有权访问根文件夹上方的文件夹时才能访问.像服务器管理员访问是必要的.
Nginx 没有 htaccess 文件。该代码需要进入 nginx 配置文件。另外,尝试在重写中添加“last”标志:
# nginx configuration
autoindex off;
location / {
rewrite .* /index.php last;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
6493 次 |
最近记录: |