将Apache规则转换为Nginx
我想将Apache Web服务器移动到ngnix Web服务器,但如何将这些Apache规则更改为ngnix。 我的主站点中有一个.htaccess文件,子目录中有一个.htaccess文件 主站点.htacess 重新启动发动机将Apache规则转换为Nginx,apache,.htaccess,nginx,Apache,.htaccess,Nginx,我想将Apache Web服务器移动到ngnix Web服务器,但如何将这些Apache规则更改为ngnix。 我的主站点中有一个.htaccess文件,子目录中有一个.htaccess文件 主站点.htacess 重新启动发动机 RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php </IfModule> <IfModule m
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ zzz.php?hash=$1 [L]
</IfModule>
RewriteCond%{REQUEST\u FILENAME}-D
RewriteCond%{REQUEST_FILENAME}.php-f
重写规则^(.*)$$1.php
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}^/index.php
重写规则^(.*)$zzz.php?哈希=$1[L]
在子目录中.htacess规则
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ host.php?hash=$1 [L,QSA,NC]
</IfModule>
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}^/index.php
重写规则^(.*)$host.php?哈希=$1[L,QSA,NC]
不要在nginx中为此使用重写规则,try\u文件要快得多:
try_files $uri $uri/ /index.php$is_args$args;
当然,您可以设置任意数量的项目并更新脚本名称,例如:
try_files $uri $uri/ /$uri.php$is_args$args; /index.php$is_args$args =404;
可用于nginx配置的服务器或位置部分:
Nginx没有类似.htaccess的东西这里有什么帮助吗