简体   繁体   English

Apache .htaccess文件到Nginx conf文件

[英]Apache .htaccess file to Nginx conf file

I have recently moved from an Apache server to an Nginx one. 我最近已从Apache服务器移至Nginx服务器。 I wasn't even aware of the fact you couldn't use .htaccess files on nginx at first, i've looked into this a little but I'm finding it very confusing on how to convert the rules of a .htaccess file to be usable on nginx. 我什至没有意识到您一开始不能在nginx上使用.htaccess文件,我对此进行了一些研究,但是我发现如何将.htaccess文件的规则转换为它非常混乱在nginx上可用。 If someone could help me out a little I would really appreciate it! 如果有人可以帮助我一点,我将非常感激!

Here is my .htaccess file: 这是我的.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

Thanks to everyone who helps in advance! 感谢提前提供帮助的每个人!

I'm use the website to converter : http://www.winginx.com/en/htaccess 我正在使用网站进行转换: http : //www.winginx.com/cn/htaccess

works for you too? 也为您工作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM