apache redirect from non www to www

前端 未结 24 934
春和景丽
春和景丽 2020-11-22 06:34

I have a website that doesn\'t seem to redirect from non-www to www.

My Apache configuration is as follows:

RewriteEngine On
### re-direct t         


        
24条回答
  •  心在旅途
    2020-11-22 07:14

    I've just have a same problem. But solved with this

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

    This rule redirecting non-www to www.

    And this rule to redirecting www to non-www

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

    Refer from http://dense13.com/blog/2008/02/27/redirecting-non-www-to-www-with-htaccess/

提交回复
热议问题