Forum Moderators: phranque

Message Too Old, No Replies

301 redirect widget.com to www.widget.com problem

         

rfontaine

1:21 pm on Oct 11, 2005 (gmt 0)

10+ Year Member



I want to make sure all links like "http://example.org" automatically go to "http://www.example.org" (with the WWW part).

I added the code below to an .htaccess file

# Make sure always goes to "www"
RewriteEngine On

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

However, for example in a browser http://example.org/news/ now goes
to http://www.example.org/public_html/news/ (why does it add the "public_html" part?)

Which gives an error.

Must be something foolish I am overlooking?

Thank you in advance

[edited by: jdMorgan at 1:36 pm (utc) on Oct. 11, 2005]
[edit reason] Examplified [/edit]

jdMorgan

1:33 pm on Oct 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are using a commercial host, you should contact them and ask about this problem. It looks as though the DocumentRoot setting is incorrect, or they have defined an Alias for your 'account'.

Also, if you are using a 'control panel' to define domains or subdomains for multiple sites, there may be a problem in the control panel settings or in the code that it generates and places in httpd.conf.

Jim

jd01

5:14 pm on Oct 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Odd, I had this exact issue stickied to me late last week by another member.

I have not heard back in a couple of days to know how things ended up, but the last suggestion was to try a 'band-aid' and either convince the host (which would not offer support) that there was a configuration error, or find a new host.

This is not ideal, but may work:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{REQUEST_URI} (.*)
RewriteRule .? http://www.example.com%1 [R=301,L]

Please, let me know if you try it.

Justin