2012-02-09 176 views
-1

如果URL中缺少它,我將添加一個http:// www。如果重定向happends .html擴展名被添加某種原因:Htaccess - 刪除擴展程序

example.com/about>的htaccess>http://www.example.com/about.html

爲什麼的.html被添加? 這是我的htaccess:

RewriteCond %{HTTP_HOST} ^example\.com$ [NC] 
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 

I'ld想有沒有的.html一部分像這樣的鏈接:

example.com/about>的htaccess>http://www.example.com/about

謝謝。 烏利

回答

0

這樣做:

Rewritecond %{REQUEST_URI} !-f 
Rewritecond %{REQUEST_URI} !-d 
Rewritecond %{REQUEST_URI} !-l 
RewriteRule ^([\w\d\-]+)$ $1.html [L] 

我建議你在你的h refs使用http://www.example.com/whatever代替http://www.example.com/whatever.html

+0

對不起,「約」部分只是一個例子。我需要一個全球解決方案。 – Uli 2012-02-09 12:28:50

+0

@Uli現在檢查。 – ThinkingMonkey 2012-02-09 12:40:19