Apache.htaccess文件到Nginx conf文件


Apache .htaccess file to Nginx conf file

我最近从Apache服务器转移到了Nginx服务器。一开始我甚至不知道你不能在nginx上使用.htaccess文件,我已经对此进行了一些研究,但我发现如何将.htacccess文件的规则转换为在nginxs上可用非常令人困惑。如果有人能帮我一点忙,我会非常感激的!

这是我的.htaccess文件:

DirectoryIndex index.php
Options -MultiViews
RewriteEngine on
RewriteCond %{THE_REQUEST} /index'.php'?page=([^'s&]*)[&'s] [NC]
RewriteRule ^ /page/%1? [R=302,L]
RewriteCond %{THE_REQUEST} /index'.php'?regiment=([^'s&]*)[&'s] [NC]
RewriteRule ^ /regiment/%1? [R=302,L]
RewriteCond %{THE_REQUEST} /error'.php'?error=([^'s&]*)[&'s] [NC]
RewriteRule ^ /error/%1? [R=302,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page/([^/]+)/?$ /index.php?page=$1 [L,QSA]
RewriteRule ^regiment/([^/]+)/?$ /index.php?regiment=$1 [L,QSA]
RewriteRule ^error/([^/]+)/?$ /error.php?error=$1 [L,QSA]
ErrorDocument 404 /error.php?error=404
ErrorDocument 403 /error.php?error=403

感谢所有提前提供帮助的人!

我正在使用网站进行转换:http://www.winginx.com/en/htaccess

对你也有用吗?