私はのようなドメインを持っていますexample.test.com
。Webサイトは、次の3つの異なるhtmlファイルで構成されています。
- 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
、理由はわかりません。