Forum Moderators: phranque

Message Too Old, No Replies

301/.htaccess

redirect to another site

         

gniver

2:53 pm on Aug 12, 2005 (gmt 0)

10+ Year Member



What should my .htaccess file look like (I'm writing my first one) if I want to permanently redirect a page to a page on another site?:

301 redirect

/old.htm

http://site-b/new.htm

[edited by: jdMorgan at 6:20 pm (utc) on Aug. 12, 2005]
[edit reason] De-linked. [/edit]

John Carpenter

4:03 pm on Aug 12, 2005 (gmt 0)

10+ Year Member



For example:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI}!^/robots [NC]
RewriteRule .* http://www.yournewdomain.com%{REQUEST_URI} [R=permanent,L]

[edited by: jdMorgan at 6:21 pm (utc) on Aug. 12, 2005]
[edit reason] Formatting. De-linked. [/edit]

John Carpenter

4:47 pm on Aug 12, 2005 (gmt 0)

10+ Year Member



By the way, the hyperlink was created automatically by this forum software (you won't include any html tags in your .htaccess file of course).

I should've used the [ pre ] tags. Sorry.

gniver

5:31 pm on Aug 12, 2005 (gmt 0)

10+ Year Member



Thanks! I tried it and what is happening now is that the entire OldSite is redirecting to the NewSite/NewPage, not just the one particular page. Here is an edited version of what I uploaded:

RewriteEngine On
RewriteBase /
RewriteCond %{OldPage.htm}!^/robots [NC]
RewriteRule .* http://www.NewSite.com/NewPage.htm%{OldPage.htm} [R=permanent,L]

So now the entire old site is redirecting to NewSite/NewPage

[edited by: jdMorgan at 6:21 pm (utc) on Aug. 12, 2005]
[edit reason] De-linked. [/edit]

jdMorgan

6:19 pm on Aug 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, you almost posted your own answer in msg#1.

RedirectMatch 301 ^/old\.htm$ http://site-b/new.htm

If the sites are separately-hosted, that's all you should need.

Jim

gniver

9:23 pm on Aug 12, 2005 (gmt 0)

10+ Year Member



Thanks Jim! Worked like a charm (of course).