2012-01-25 224 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; 
    } 
}