homepage Welcome to WebmasterWorld Guest from 54.196.168.78
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 old domain to new domain
wheelie34




msg:4225422
 2:35 pm on Nov 2, 2010 (gmt 0)

Hi all (Jim)

After reading many posts just want to check it is this simple

redirect 301 / http://www.new-domain.co.uk/
redirect 301 /folder/ http://www.new-domain.co.uk/
redirect 301 /folder/page.htm http://www.new-domain.co.uk/folder/


The above htaccess will be placed on the old domains hosting.

Do I need anything else in the htaccess, there are no other url's that I need redirecting just folder names and page names, are the above in the correct order or would the first one / overrule the ones below it, I would, for traffic reasons, like to have the folders redirect properly.

Thanks for looking

 

g1smd




msg:4225435
 2:58 pm on Nov 2, 2010 (gmt 0)

The first rule will redirect all URL requests arriving at the old site. The other two rules will never get to run.

Place the "more specific" redirects first, and the general "/" redirect last; exactly the reverse order of what you have now.


You'll also need rules for "index.html" requests, and those will redirect to new URL without index filename included.

wheelie34




msg:4225567
 6:14 pm on Nov 2, 2010 (gmt 0)

You'll also need rules for "index.html" requests, and those will redirect to new URL without index filename included.


I have always run root urls, had the redirect to / for years on the old site, do I still need to worry about that?

g1smd




msg:4225603
 7:12 pm on Nov 2, 2010 (gmt 0)

Yes you do, because if something asks for oldside.com/index.html, your newly installed rules will redirect to newsite.com/index.html and only then will the new site redirect to newsite.com/, and that's two steps.

You need to avoid the redirection chain happening, by redirecting index requests at the old site directly to the new URL on the new site.

wheelie34




msg:4270595
 4:07 pm on Feb 22, 2011 (gmt 0)

Hi g1smd, ok I now have all old urls in the htaccess file, I just tried to test it but got error 500

the very first line of the new htaccess is

redirect 301 /page.php [new-domain.co.uk...]

then 100s of redirect 301 lines and my last line is

redirect 301 / [new-domain.co.uk...]

Is anything else needed?

This is the top of the original htaccess

ErrorDocument 404 /404.htm
AddHandler server-parsed .html
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
Options +FollowSymLinks
RewriteEngine on
# redirect non-www to www subdomain.
RewriteCond %{HTTP_HOST} ^old-domain\.com [NC]
RewriteRule (.*) [old-domain.com...] [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.htm
RewriteRule (.*) [old-domain.com...] [R=301,L]

g1smd




msg:4270642
 5:36 pm on Feb 22, 2011 (gmt 0)

The first RewriteRule rule redirects all requests so the final rule never gets to run.

You must have the more-specific index redirect listed before the less-specific non-www redirect.

Do not mix Redirect and RewriteRule syntax in the same file.

Use RewriteRule for all of your redirects and list them most-specific to least-specific.

Alter redirects within the old site to now point to the new site.

wheelie34




msg:4270651
 6:09 pm on Feb 22, 2011 (gmt 0)

OK I knew I shouldnt have posted the old htaccess code, I think you have missunderstood, this is all I have in the NEW htaccess

the very first line of the new htaccess is

redirect 301 /page.php [new-domain.co.uk...]

then 100s of redirect 301 lines and my last line is

redirect 301 / [new-domain.co.uk...]

Is anything else needed?

I get error 500 when trying to run it, the rewites etc are in the old sites current htaccess, not in the new htaccess which is to redirect all traffic

wheelie34




msg:4270945
 8:55 am on Feb 23, 2011 (gmt 0)

I really need to get this right, the OLD site already has code in its htaccess file

ErrorDocument 404 /404.htm
AddHandler server-parsed .html
RemoveHandler .html .htm
AddType application/x-httpd-php .php .htm .html
Options +FollowSymLinks
RewriteEngine on
# redirect non-www to www subdomain.
RewriteCond %{HTTP_HOST} ^old-domain\.com [NC]
RewriteRule (.*) [old-domain.com...] [R=301,L]
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.htm
RewriteRule (.*) [old-domain.com...] [R=301,L]

Do I keep all the above in the OLD sites htaccess and add all my redirect 301 rules below it?

redirect 301 /page.php [new-domain.co.uk...]
then 100s of redirect 301 lines and my last line is
redirect 301 / [new-domain.co.uk...]

I have created a new htaccess that only has line afer line of redirect 301 entries. I tried it and got error 500

I'm confused

wheelie34




msg:4270959
 10:06 am on Feb 23, 2011 (gmt 0)

Would it be best to JUST use this in the old sites htaccess

redirect 301 / [new-domain.co.uk...]

Then use many lines like this, for each page

redirect 301 /page-name.htm [new-domain.co.uk...]

in the htaccess file of the NEW site

wheelie34




msg:4270977
 11:36 am on Feb 23, 2011 (gmt 0)

ok progress, one redirect had a space which caused the error so no wit works BUT there are a few redirects that are not doing what they should, here's one

redirect 301 /folder/file.htm [new-domain.co.uk...]

when it gets there the address bar is showing

[new-domain.co.uk...]

Where do I look? old site? new site?

jdMorgan




msg:4276729
 6:49 pm on Mar 4, 2011 (gmt 0)

Already posted above:

> Do not mix Redirect and RewriteRule syntax in the same file.

This is important, as are all the other points.

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved