Forum Moderators: phranque

Message Too Old, No Replies

www redirect working but Server not found Get the error message

         

vasanth

3:22 pm on Jul 22, 2014 (gmt 0)

10+ Year Member



www redirect working but Server not found Get the error message.. This same code we tried last domain that is working good..but here I can't solve this.



Options +FollowSymLinks -MultiViews
RewriteEngine on

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



Thank you

not2easy

3:48 pm on Jul 22, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



In your Rule you are specifying a query string ($) that is not mentioned in the Cond. Also, the condition needs to escape the . with \.

The [R=permanent,L] is best expressed as [R=301,L]

You may have different versions of Apache on one host and another so that in one case it manages to do the job. Also you probably have other rules in place and it could be that another rule manages to make it work. (?)

lucy24

5:53 pm on Jul 22, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"Server not found" doesn't sound like an Apache error. It sounds like a DNS problem.

In your Rule you are specifying a query string ($) that is not mentioned in the Cond.

Did something get edited after this was posted? The rule as written captures the path of the request ($1 for capture from rule, not %1 for capture from condition) and reappends it to the canonical form of the hostname.

The optimal form of a domain-name-canonicalization redirect is
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$

i.e. "If the named host is anything other than exactly the preferred form or exactly nothing."