.htaccess - redirect non-www to www resulting in loop address -
i'm configuring website redirect non-www www, resulting in address loop this:
abc.com/www.abc.com/index.php/www.abc.com/index.php/www.abc.com/index.php/www.abc.com/index.php/www.abc.com/index.php ... , on
below .htaccess file. can me spot error?
<ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewritecond %{request_uri} ^system.* rewriterule ^(.*)$ /index.php?/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico) rewriterule ^(.*)\.html$ /index.php/$1 [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^(/index\.php|/assets|/robots\.txt|/favicon\.ico) rewriterule ^(.*)$ /index.php/$1 [l] rewritecond %{http_host} !^www\. rewriterule ^(.*)$ www.%{http_host}/index.php/$1 [r=301,l] </ifmodule> <ifmodule !mod_rewrite.c> errordocument 404 /index.php </ifmodule>
many thanks,
rewriterule ^(.*)$ www.%{http_host}/index.php/$1 [r=301,l] ^---
you forgot prefix hostname http://
, apache's rewriting local url
try
rewriterule ^(.*)$ http://www.%{http_host}/index.php/$1 [r=301,l]
instead.
it's same rules apply to:
<img src="www.example.com/kittens.jpg" /> <img src="http://www.example.com/kittens.jpg" />
Comments
Post a Comment