homepage Welcome to WebmasterWorld Guest from 54.211.68.132
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

    
Remove url params from any URL on a site
wildwill




msg:4548174
 12:17 pm on Feb 23, 2013 (gmt 0)

Hiya all

I have a site that has a small issue with duplicate content and I need to redirect page requests to remove the URL Params.

so direct any requests that have "?category_id=" and then any number after it, to the same url just without the URL params.

So:
[sitename.com...]

redirect to:
[sitename.com...]

Any ideas?

wW

 

g1smd




msg:4548177
 2:04 pm on Feb 23, 2013 (gmt 0)

Use a RewriteRule. The RegEx pattern will match the path part of the URL request, and only the path part. The target of the Rule will be the new URL. Use a question mark to suppress parameters from being re-appended to the new URL. Add flags to force the 301 status and to make it the Last rule if the pattern matched.

You'll need a preceding RewriteCond. This will look at THE_REQUEST and match requests that include the path and parameter that you want to redirect.

It's a couple of lines of code, and there's many previous examples as this question comes up several times per month.

wildwill




msg:4548184
 2:15 pm on Feb 23, 2013 (gmt 0)

Howdy g1smd thank you for your reply.

I am familiar with adding things to the .htaccess file, but do you have any examples of this rewriteRule?

wilderness




msg:4548187
 2:34 pm on Feb 23, 2013 (gmt 0)

but do you have any examples of this rewriteRule?


The closing line of his reply.

It's a couple of lines of code, and there's many previous examples as this question comes up several times per month.

wildwill




msg:4548191
 3:06 pm on Feb 23, 2013 (gmt 0)

ok thnx yall

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