Forum Moderators: phranque

Message Too Old, No Replies

Redirecting old sites pages to new sites pages

Can't think straight anymore, need help

         

SincerelySandy

4:39 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



I'm sorry to have to ask this because I know the answer is already here in this forum. It's been a hard week and I'm just too brain dead or scattered to work it out.
Using an .htaccess file, I want to permanently redirect all the pages of my old site to my new site. For example ... oldsite.com/good-red-widgets.html should redirect to www.newsite.com/red-widgets.html ,
oldsite.com/good-green-widgets.html should redirect to
www.newsite.com/green-widgets.html .
I also want to redirect oldsite.com/index.html and www.oldsite.com/index.html to www.newsite.com/index.html

If someone could kindly post the snippet of code needed to do this with an .htaccess file I would greatly appreciate it. Just an example using a couple interior pages as well as my index page should be sufficient for me to figure out how to do it with all my pages. I don't have too many pages so I don't mind redirecting each page.

Thank you for any help.

jdMorgan

5:00 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Are the two domains hosted in the same "account" on the same server? If so, then the answer is a bit more complicated.

If not, simply put


Redirect 301 / http://www.[b]new[/b]domain.com

in http://www.olddomain.com/.htaccess, and that's all you'll need to redirect the entire old domain and all pages in it.

Jim

SincerelySandy

5:38 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



I wish it was that easy. The domains are under different accounts with different IP addresses.
Since I don't have that many pages, would it be better to redirect each page to it's new place on the new site?
Thanks for taking the time to reply so quick JD.

jdMorgan

6:14 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you misread what I wrote: It is easier with separate hosting -- Just use the one-line redirect above.

Jim

SincerelySandy

8:39 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



You were right, I did not correctly read what you said, did I mention I'm a little brain dead? :-)
Anyway here is what is working for me but I just wanted to make sure that the code is not incorrect somehow?
Thanks for being here JD
redirect 301 /big-red-widgets.html http://www.newsite.com/redwidgets.html
redirect 301 /big-blue-widget.html http://www.newsite.com/big-blue-widget.html
redirect 301 /index.html http://www.newsite.com/

jdMorgan

9:02 pm on Mar 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You only wish to redirect three pages? In your original post, you said you wanted to redirect the whole site...

If you need to change a few page-URLs, you can use your individual Redirects, and then follow them with the code I posted above to handle the page-URLs that did not change:


# Redirect a few pages to new page URLs on new site
Redirect 301 /big-red-widgets.html http://www.newsite.com/redwidgets.html
Redirect 301 /index.html http://www.newsite.com/
#
# Redirect all the rest of the pages and objects to the corresponding files on the new domain
Redirect 301 / http://www.newsite.com/

In case it's not obvious, "Redirect" uses prefix-matching, so any request for a URL that *starts* with what you type as the left-hand Redirect URL-path gets redirected to what you type as the right-hand Redirect URL, with any part of the requested URL that you didn't specify on the left added to the the URL on the right.

Therefore, the last Redirect I added above will redirect an entire site all by itself. And the only reason that the two preceding lines are needed is because you've changed the page name, so you don't want the old page-URLs carried forward to the new site.

Ref: [httpd.apache.org...]

Jim

[edited by: jdMorgan at 9:04 pm (utc) on Mar. 10, 2007]

SincerelySandy

9:32 pm on Mar 10, 2007 (gmt 0)

10+ Year Member



Sorry for the confusion. Yes I am redirecting the whole site. I used the code for those 3 pages as an example. The code was from the last 3 lines of my .htaccess file. I have changed all the page names on the new site (shortened names and got rid of hyphens), the only page name that didn't change is the index.html page.
So am I correct to assume that the code below would be more efficient than the code I posted previously? the only difference is the last line.
redirect 301 /big-red-widgets.html http://www.newsite.com/redwidgets.html
redirect 301 /big-blue-widget.html http://www.newsite.com/bluewidget.html
redirect 301 / http://www.newsite.com/