Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

3 old URLs to 1 new URL: 301 them all or 404 gone?

         

JackR

8:33 pm on Oct 25, 2011 (gmt 0)

10+ Year Member



I'm rewriting the URL structure on one section of my site to move a bunch of similar content onto a single, comprehensive page.

Is it best to .301 redirect all 3 of the vintage URLs to the single new URL, or should I .404 the old URLs and let Google drop them in time?


If it's a .301, is this correct?


Redirect 301 /the_old_page.htm http://www.example.com/example.html
Redirect 301 /the_old_page2.htm http://www.example.com/example.html
Redirect 301 /the_old_page3.htm http://www.example.com/example.html

realmaverick

8:53 pm on Oct 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



404 isn't gone. 404 is page not found. 410 is page gone and will help prevent Google from keep trying and trying for the page.

However I would 301 redirect the pages to the single page, if you're certain that you want to merge the pages.

The redirect looks fine. Obviously test the pages once applied :)

g1smd

10:10 pm on Oct 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I would redirect. Use a RewriteRule for this.

RewriteRule ^the_old_page[123]?\.html? http://www.example.com/example.html [R=301,L]


The RewriteRule should be listed early in the .htaccess file, certainly BEFORE any other canonicalisation rules.

lucy24

10:40 pm on Oct 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



overlapping g1

You could also use RedirectMatch:

RedirectMatch 301 /(the_old_page|the_old_page2|the_old_page3)\.html? http://www.example.com/example.html

Regular Expressions in the pattern, no change in the target.

Same principle for the Rewrite version.

Edit: The difference between g1's RegEx and mine is because he took your page names literally and I took them figuratively. You'll know which version applies.

JackR

11:10 pm on Oct 25, 2011 (gmt 0)

10+ Year Member



Thanks for the replies.

2 of the pages are .html and the other is .htm


Is this correct:

RewriteRule ^the_old_page1?\.html? http://www.example.com/example.html [R=301,L]
RewriteRule ^the_old_page2?\.html? http://www.example.com/example.html [R=301,L]
RewriteRule ^the_old_page3?\.htm? http://www.example.com/example.html [R=301,L]

g1smd

11:30 pm on Oct 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use one rule with the local OR functionality to combine the names within one RegEx pattern.

The .html? part matches both .htm and .html so it ensures that both versions are redirected.

JackR

8:42 am on Oct 26, 2011 (gmt 0)

10+ Year Member



Second try:

RewriteRule ^the_old_page1|^the_old_page2|^the_old_page3?\.html? http://www.example.com/example.html [R=301,L]


or should it be:

RewriteRule ^the_old_page1|the_old_page2|the_old_page3?\.html? http://www.example.com/example.html [R=301,L]

lucy24

9:58 am on Oct 26, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Neither. If all the pages are in the top level, it's

^(the_old_page1|the_old_page2|the_old_page3)\.html?

If they're not all in the top directory, you have to leave off the beginning anchor or include the rest of the path. Pipes are processed before anything else, so your second version is equivalent to

^the_old_page1 [OR]
the_old_page2 [OR]
the_old_page3?\.html?

What's the question mark doing after the 3?

JackR

10:56 am on Oct 26, 2011 (gmt 0)

10+ Year Member



Thanks Lucy

As one file is in a sub folder, I think this is now correct:

RewriteRule ^(the_old_page1|the_old_page2|/folder/the_old_page3)\.html? http://www.example.com/example.html [R=301,L]



or is it:


RewriteRule ^(the_old_page1|the_old_page2|folder/the_old_page3)\.html? http://www.example.com/example.html [R=301,L]

lucy24

8:05 pm on Oct 26, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



In the "pattern" part of a RewriteRule, leave off the leading directory slash. So it's #2.

g1smd

11:34 pm on Oct 26, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use a separate rule for the one in the other folder.

If the names are similar, use
RewriteRule ^the_old_page[12]\.html? http://www.example.com/example.html [R=301,L] 
RewriteRule ^folder/the_old_page3\.html? http://www.example.com/example.html [R=301,L]


If the names are not similar use:
RewriteRule ^(gadgets|doodads)\.html? http://www.example.com/example.html [R=301,L] 
RewriteRule ^folder/armadillo\.html? http://www.example.com/example.html [R=301,L]