【问题标题】:Apache .htaccess file to Nginx conf fileApache .htaccess 文件到 Nginx conf 文件
【发布时间】:2016-07-15 09:21:41
【问题描述】:

我最近从 Apache 服务器转移到 Nginx 服务器。我什至不知道你一开始不能在 nginx 上使用 .htaccess 文件这一事实,我对此进行了一些研究,但我发现如何将 .htaccess 文件的规则转换为可以在 nginx 上使用。如果有人能帮我一点忙,我将不胜感激!

这是我的 .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

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

【问题讨论】:

标签: php .htaccess nginx server


【解决方案1】:

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

也适合你?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-10
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    相关资源
    最近更新 更多