homepage Welcome to WebmasterWorld Guest from 54.211.47.170
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Please check my htaccess redirect code.
416bc




msg:4204359
 6:31 pm on Sep 20, 2010 (gmt 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.

 

Spiekerooger




msg:4204795
 2:53 pm on Sep 21, 2010 (gmt 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.

jdMorgan




msg:4204823
 3:41 pm on Sep 21, 2010 (gmt 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

416bc




msg:4204921
 6:23 pm on Sep 21, 2010 (gmt 0)

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

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