2012-01-25 315 views
0

我想转换一个简单的.htaccess文件(规则)用于nginx。我尝试在googleit之后访问一个在线工具,但该网站已关闭。所以,如果有人愿意帮忙,我会很感激。谢谢。这里是我的.htaccess文件:.htaccess到nginx重写规则

选项+ +了FollowSymLinks ExecCGI

<IfModule mod_rewrite.c> 
    RewriteEngine On 

    # we skip all files with .something 
    RewriteCond %{REQUEST_URI} \..+$ 
    RewriteCond %{REQUEST_URI} !\.html$ 
    RewriteRule .* - [L] 

    # we check if the .html version is here (caching) 
    RewriteRule ^$ index.html [QSA] 
    RewriteRule ^([^.]+)$ $1.html [QSA] 
    RewriteCond %{REQUEST_FILENAME} !-f 

    # no, so we redirect to our front web controller 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 

回答

1

请,请尝试以下规则:

# Deny all files that started with dot 
location ~ /\. { 
     deny all; 
} 
# Try $uri - is file, $uri/ - is dir, index.html - caching, $uri.html caching, index.php -last 
location/{ 
     try_files $uri $uri/ index.html $uri.html index.php; 
} 
0

请,请尝试以下规则:

# nginx configuration 

location ~ \.html$ { 
} 

location/{ 
    if ($request_uri ~ "\..+$"){ 
    rewrite ^/$ /index.html; 
    } 
    rewrite ^/([^.]+)$ /$1.html; 
    if (!-e $request_filename){ 
    rewrite ^(.*)$ /index.php break; 
    } 
}