How to redirect non-www to www URL's using htaccess?

前端 未结 4 1742
暗喜
暗喜 2020-11-29 01:38

I have a website say http://www.example.com/ in the root of my website, I have added .htaccess file to redirect any request of http://example.com/ to http://www.example.com/

4条回答
  •  眼角桃花
    2020-11-29 02:10

    This is Best Solutions to redirect non-www to www URL's using htaccess. using this code in htaccess file and check url.

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^mydomain.com [nc]
    rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]
    

提交回复
热议问题