Forum Moderators: open

Message Too Old, No Replies

Redirect with 301 error

         

kapow

2:12 pm on Oct 18, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can anyone tell me how to get every page on a site to do a redirect (client side) to another site, with a 301 error ? Both sites are on Apache servers.

My reasons for doing this are on this thread: [webmasterworld.com...]

bobriggs

2:59 pm on Oct 18, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look here:

Apache mod_alias [httpd.apache.org]

kapow

9:35 am on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for the link.

On the instruction I saw the following:
-------------------
Syntax: Redirect [status] URL-path URL

Example:
Redirect /service [foo2.bar.com...]
If the client requests [myserver...] it will be told to access [foo2.bar.com...] instead.

permanent
Returns a permanent redirect status (301) indicating that the resource has moved permanently.
-------------------

Would someone tell me if I understand this right?

Lets say that the wrong site is called www.bigspanners.com and the new correct site is called www.mysite.com

So should I create a .htaccess file with the following contents:

Redirect [permanent]/www.bigspanners.com//www.mysite.com/

And put that in the root folder of www.bigspanners.com - or should it go in every folder???

bobriggs

1:23 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've only had to do this once, and it is an internal redirect into my own site, but I can answer a couple of these questions.

1. You only need to put this in the .htaccess of the root folder - (The .htaccess is cascaded in all higher level directories)

2. I don't think you put the domain name in URL-path; just leave it /

3. If the whole site is mirrored, then that's all you should need. But if you've renamed pages, or moved to different named folders, you'll need multiple redirect lines.

I would just try it. If it doesn't work, you can remove it.

kapow

1:52 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK - I just tried these (and a few other variations) and it didn't work.

redirect [permanent] [wrongdomain.com...] [mydomain.com...]

and

redirect [permanent] [mydomain.com...]

What am I doing wrong ??? :(

ps: (.htaccess works on other sites on the same server for password access etc).

bobriggs

2:16 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try

redirect permanent / [mydomain.com...]

No brackets.

If that doesn't work, try removing the trailing slash after .com[/]

kapow

2:29 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




:) Y E S !!! :)

Slade

3:34 pm on Oct 19, 2001 (gmt 0)

10+ Year Member



I asked in a forum somewhere for this type of answer and was given "RewriteRule" as an answer.
I've successfully used this to move pages around on my client's site. Is there any advantage or logic for one over the other?

Xoc

5:22 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For further documentation, to do the same thing in IIS:

Let's suppose that you have a web site [domain.com...] and you want [domain.com...] to do a client-side 301 error redirect to the [domain.com...] site.

To perform the redirect, suppose that the content for www.domain.com comes from c:\inetpub\ www-domain-com:


  1. Open Internet Services Manager and create a web site for domain.com. Make the content directory for the site be the same directory, c:\inetpub\ www-domain-com, as www.domain.com.
  2. Test getting content from [domain.com....] This should work, but won't redirect yet.
  3. Select the domain.com web site in Internet Services manager and enter the properties.
  4. In the Home Directory tab, change the option button "When connecting to this resource the content should come from" to "A redirection to a URL".
  5. Specify the URL as [domain.com....]
  6. Check the checkbox that says "A permanent redirection for this resource."

This is a picture of the dialog [xoc.net].

jeremy goodrich

5:26 pm on Oct 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hmm...been trying to get this to work in my site, after reading this thread, and the apache docs...

tried:
redirect permanent [mydomain.com...] [mydomain.com...]

Didn't work, other variations didn't either. Any tips?

kapow

7:29 am on Oct 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Geremy

Well I put the following into a file called .htaccess and it worked:

redirect permanent / [mydomain.com...]

Marcia

7:42 am on Oct 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Redirect 301 / [otherdomain.com...]

kapow

12:27 pm on Oct 22, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Marcia
I just changed my .htaccess to your suggestion and that works too. Your recommendation looks better to me (not knowing much about this) as it says '301' - I feel more confident that Google will reolise this is a permanent change now.

kapow

3:03 pm on Oct 29, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I see that
Redirect 301 / [otherdomain.com...]
automatically forwards my browser to www.otherdomain.com

Does that mean that I can remove the content from the old domain? I would rather just have an index page that says this site has moved to www.otherdomain.com. I'm thinking that this would help my 'otherdomain' get its PR back.

msr986

11:35 pm on Nov 11, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> hmm...been trying to get this to work in my site, after reading this thread, and the apache docs...
tried:
redirect permanent [mydomain.com...] [mydomain.com...]

Didn't work, other variations didn't either. Any tips?

Yes found the answer:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.MY_DOMAIN\.com [NC]
RewriteRule ^(.*) [MY_DOMAIN.com...] [L]

Marty

Warp

1:58 am on Dec 10, 2001 (gmt 0)

10+ Year Member



you could use the RedirectPermanent directive

[httpd.apache.org...]

Gorufu

10:01 am on Dec 10, 2001 (gmt 0)

10+ Year Member



Warp, welcome to WebmasterWorld!

kapow, all the following produce a 301 error

RedirectPermanent
Redirect permanent
Redirect 301

> Does that mean that I can remove the content from the old domain?

Yes, provided that you keep the same directory structure and filenames for the new domain.

> I feel more confident that Google will reolise this is a permanent change now.

IMHO and based on experience Google will recognize the permanent redirect. All the old domain and pages, should be replaced with the new domain and pages.

I know that it works for 301 redirects within a domain. I renamed several of my pages and Google removed all the old pages and replaced them with the new pages.