简体   繁体   中英

Redirect index.html to root htaccess and non www to www?

I have written this code is this right or wrong?

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

RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.cogxim.com/$1 [R=301,L]

Specify like this to redirect non-www traffic to www

    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} ^.*/index.html
    RewriteRule ^(.*)index.html$ http://www.cogxim.com/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^cogxim.com
    RewriteRule (.*) http://www.cogxim.com/$1 [R=301,L

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM