将htaccess规则路由路径转换为index.php到nginx

时间:2014-12-08 18:37:24

标签: apache .htaccess nginx

我是nginx的新手,但我试图转换

# Disallows file browsing
Options -Indexes
# Custom Error Pages
ErrorDocument 403 /error-docs/403.php
ErrorDocument 404 /error-docs/404.php
ErrorDocument 500 /error-docs/500.php
# Turn on the Apache Rewrite Engine
RewriteEngine On
#Conditional to see if it is a real file or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# If not then pass the query string to index.php and stop any further rules
RewriteRule (.*) index.php/$1 [PT,L]

到nginx语法。我在Routing requests through index.php with nginx尝试了这个建议,但它并没有完全按照我的需要去做。我还尝试过自动转换器http://winginx.com/en/htaccesshttp://www.anilcetin.com/,但他们输出的规则对我来说也不起作用。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

我遇到的问题实际上与我的PHP和MySQL代码有关。

location / {
    try_files $uri $uri/ /index.php$args;
}

工作正常。感谢您的链接。