0

How to redirecting non-www to www with .htaccess for all page's? in my main page(index) works, but if i go mywebsite.com/page2, will not redirect me to my preference domain www.mywebsite.com/page2. How can i fix it?

3
Contributors
12
Replies
40
Views
2 Years
Discussion Span
Last Post by cristian.stilpeanu.1_1
0

Yes man i know that, but works just from index page, if i type myweb.com/page1 dosen't redirect me to www.myweb.com/page1

0

the $1 parameter passes everything after .com to the rewritten url
it should work
except when something is missed or changed on the server config.
many servers are locked down, and if the locking is . .. . less than perfect . ..
try

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

which covers the more common apache config errors

one stupid little carat

Edited by almostbob

0

then its not an apache config error
your code is not good

line 4, there should not be a nocase [NC] flag it should be L,
rewrite condition in line 3 creates an infinite loop
search for mysite.com in the host string, redirect to www
then do it again to the redirect url, and again and again

the code samples given all have a rewrite condition
RewriteCond %{HTTP_HOST} !^www\.
search for url that do NOT include www., and redirect to www.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.