2011-03-17 139 views
0

更改我的網站結構後,我需要幫助重定向鏈接。我如何將所有沒有.html擴展名的鏈接重定向到同一鏈接但帶有.html擴展名?我不想重定向的唯一鏈接是/ admin。重定向不帶.html擴展名的鏈接以鏈接.html擴展名

Example: google.com/hey -> google.com/hey.html 
     google.com/hey.html -> do nothing 
     google.com/admin -> do nothing 

在此先感謝

回答

1

喔很抱歉,請這個人。錯誤發生在rewritecond。

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !\.html$ 
RewriteRule (.+) $1.html [L] 
+0

%{} REQUEST_FILENAME!\。html $進行將導致所有的CSS,JS和其他資源,一併改寫... – squarecandy 2013-02-09 23:33:04

0

如果這些鏈接的onpage鏈接的非外部因素。htaccess的解決方案可以幫助。 首先要注意,只有當您無法訪問服務器配置時才使用htaccess,因爲htaccess會降低服務器速度。在那裏配置的所有東西都可以配置.httpdconf

對不起,我沒有測試過的代碼,但告訴我它是否工作。 http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} > \.html 
RewriteRule (.+) $1.html [L] 
+0

我得到了一個500錯誤 – 2011-03-17 04:11:07