2014-12-10 127 views
1

好的,也許我是轉儲,但我簡單的重寫.htacces規則不起作用。我只想在我的網站上,例如www.mysite.com/something.html將重寫規則更改爲www.mysite.com/something。我yust想從文件中刪除something.html .html和獲取內容簡單重寫規則

現在我有這個在我的.htacces文件,但不工作:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.+)$ $1.html [L,QSA] 
AddType application/x-httpd-php5 .htm .html 

回答

2

您需要重定向.html另一條規則:

RewriteEngine On 

# To externally redirect /dir/file.php to /dir/file 
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC] 
RewriteRule^/%1 [R=302,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}.html -f 
RewriteRule ^(.+)$ $1.html [L,QSA] 
AddType application/x-httpd-php5 .htm .html 
+1

謝謝,它的作品像魅力:-D – 2014-12-11 07:58:28

+0

不客氣,很高興它解決了。 – anubhava 2014-12-11 08:06:31