Forum Moderators: phranque

Message Too Old, No Replies

need 301 redirect help on VPS

tried everything, still get errors

         

brokenbricks

6:56 pm on Jun 21, 2005 (gmt 0)

10+ Year Member



I want to redirect domain.com to www.domain.com

Sounds simple enough, but I haven't got it working. I've read several posts countless times and still can't find the problem.

Background: I am on a VPS (virtual private server) and I have 4 domains sharing that account and IP address. I don't know if this is maybe why I've been having problems...
I would like to code to work for all of them if possible...

The latest code I tried gives me an internal server error when I type in [domain.com...] and [domain.com...]

Options +FollowSymLinks
AllowOverride FileInfo
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]

.htaccess really is not my specialty, is my code terribly wrong or is this something to do with my server?

I have also tweaked this code a bunch of times from other examples I've found here, but nothing still.

jd01

11:51 pm on Jun 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi brokenbricks,

Your code looks good. I am not sure about the server question, I normally just write code, but try not to play with servers =). Have you tried removing or commenting out the first two lines of your code? IOW the AllowOverride, and the Options?

If you have not, please try removing these and see what happens... there are times when you can set an option or override, that will cause an error, because it is in conflict with a setting in the config file and you may not have permission to change them in the .htaccess (most of the time, I do not use either of these two lines of code.)

Please, let me know if this makes any difference so I will know for future questions.

Hope this helps.

Justin

brokenbricks

3:34 pm on Jun 22, 2005 (gmt 0)

10+ Year Member



I managed to get it to work this way:

RewriteEngine on
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule (.*) [domain.com...] [R=301,L]

I have a problem on another domain I have though.

Let's say I have www.domain.com and www.domain.com/directory/

directory is unrelated to www.domain.com so decided to move it to www.newdomain.com/directory/

in www.domain.com/directory/ .htaccess I had it set up to:
Redirect permanent / [newdomain.com...]

This worked succesfully for www.domain.com/directory/ 301 redirecting to www.newdomain.com/directory/

Using the same 301 redirect from the top, for www.domain.com's .htaccess

the directory now leads to www.domain.com (the unrelated site) and not www.newdomain.com/directory/ like before.

Following?
What can I do about this?

In another question, I have 404 and 403 errors forwarded to my www.domain.com , I just realized and wondered is this a bad idea? I noticed that spider crawled a deleted page and now shows that url the same as my index.html. Is this a problem? Should I create a seperate page to forward 403 and 404 errors? I'm worried about dupe content.

Thanks so much

jdMorgan

5:35 pm on Jul 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using the same 301 redirect from the top, for www.domain.com's .htaccess

the directory now leads to www.domain.com (the unrelated site) and not www.newdomain.com/directory/ like before.

Following?
What can I do about this?

Try:


Redirect permanent /directory/ http://www.newdomain.com

In another question, I have 404 and 403 errors forwarded to my www.domain.com , I just realized and wondered is this a bad idea? I noticed that spider crawled a deleted page and now shows that url the same as my index.html. Is this a problem? Should I create a seperate page to forward 403 and 404 errors? I'm worried about dupe content.

Yes, redirecting error documents to another domain is a big mistake. The reason for this is described in the ErrorDocument documentation [httpd.apache.org]; When an ErrorDocument is defined with a canonical URL (meaning it contains a domain name in addition to the local URL-path), then the server will produce a 302-Moved Temporarily response code, instead of the expected 403 or 404 response code. Therefore, the spider will not see an error code, but rather a 302 redirect code. So, it will not treat this URL request as an error, and will list the errordocument page's content with the originally-requested URL.

Jim

Thanks so much