0
我有一個域名,如example.test.com
。該網站由三個不同的HTML文件:mod_rewrite在Chrome和Internet Explorer中無法在Firefox中使用
- 的index.html
- products.html放在
- contact.html
因此,如果example.test.com/index.html
用戶鍵入的URL應該被重定向到example.test.com
。
而且example.test.com/index
應該成爲example.test.com
example.test.com/contact.html
應該example.test.com/contact
等。
他們應該是沒有www
之前的url。
我想出了以下規則:
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} !^example.test.com$ [NC]
RewriteRule ^(.*)$ http://example.test.com/$1 [L,R=301]
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.html !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)\.html$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.html -f
RewriteRule [^/]$ %{REQUEST_URI}.html [QSA,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(html?|php)\ HTTP/
RewriteRule ^index\.(html?|php)$ http://example.test.com/ [R=301,L]
在Firefox中一切正常,但在Chrome和Internet Explorer example.test.com/index.html
只重定向到example.test.com/index
,我不知道爲什麼。