Redirect non-www to www in .htaccess

后端 未结 13 1755
轻奢々
轻奢々 2020-11-22 05:51

I have this in my .htaccess file:

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

but whenever I

13条回答
  •  囚心锁ツ
    2020-11-22 06:20

    Add the following code in .htaccess file.

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

    URLs redirect tutorial can be found from here - Redirect non-www to www & HTTP to HTTPS using .htaccess file

提交回复
热议问题