Welcome to WebmasterWorld Guest from 54.196.231.129

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Please check my htaccess redirect code.

     
6:31 pm on Sep 20, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 14, 2010
posts: 31
votes: 0


I've tried various lines in my htaccess, I'm a little new to it, but here's what I have so far


RewriteRule ^node/([0-9+]+)/revisions/([0-9+]+)/view$ /node/$1? [L,R=301]


What I'm trying to do is this.
if url = mywebsite.com/node/123/revisions/234/view then point them to mywebsite.com/node/123 and leave off the rest.

Thanks for the help.
2:53 pm on Sept 21, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 12, 2005
posts:45
votes: 0


You do not need the plus in the square brackets, just the ones after the closing square bracket (is square bracket the right english word? - I'm talking about those: [] ). Otherwise your code should be fine.
3:41 pm on Sept 21, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


To prevent hostname canonicalization problems if your server is configured (now or later) with "UseCanonicalName On" and a non-canonical hostname is declared as the "ServerName," always specify the canonical hostname in any external redirect rule. That is:

# Externally redirect to remove revision number and "/view" from the client-requested URL-path
RewriteRule ^node/([0-9]+)/revisions/([0-9]+)/view$ http://www.example.com/node/$1? [R=301,L]

The most common manifestation of this problem is when the Webmaster has opted to use "www.example.com" and most or all inbound links point to that hostname, but ServerName is defined as "example.com" and UseCanonicalName is on. In cases like that, any request that triggers the rule will end up being redirected to the non-canonical hostname, and then perhaps get redirected again back to the canonical hostname (if you also have a rule to do that), resulting in stacked/chained/multiple redirects.

Search engines "don't like" chained redirects: They will be reported as errors in "Webmaster Tools" reports, and will not pass full ranking credit from old/incorrect URL links to the new/correct URL. And if no hostname canonicalization rule is in place, then the redirect to the non-canonical hostname effectively 'splits' your page-ranking credit, creates duplicate-content, and makes your site rely on the search engines' back-end de-duplication processes to 'clean up the mess."

Jim
6:23 pm on Sept 21, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 14, 2010
posts: 31
votes: 0


Thanks guys! And Thanks Morgan for the detailed tutorial! :)