我需要协助将以下htaccess规则转换为Nginx。
AddHandler php5-script .php .html .html
AddType text/html .php .html .html
Opt0ions -Indexes
ErrorDocument 403 /index.php
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
#RewriteRule ^(.*)$ test.php/$1
RewriteRule ^(.*)$ index.php/$1
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
到目前为止,我有以下内容,但不知道如何在Nginx中实现这一点:
# nginx configuration
error_page 403 /index.php;
autoindex off;
location / {
if ($script_filename !~ "-f"){
rewrite ^(.*)$ /index.php/$1;
}
if ($http_host ~* "^www\.(.*)$"){
rewrite ^(.*)$ http://%1/$1 redirect;
}
}
我已转换为http://winginx.com/en/htaccess
转换后的重写规则是否正确?我如何用Nginx实现这些?