Welcome to WebmasterWorld Guest from 54.205.60.49

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Remove url params from any URL on a site

   
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
2:04 pm on Feb 23, 2013 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
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?
2:34 pm on Feb 23, 2013 (gmt 0)

WebmasterWorld Senior Member wilderness is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.
3:06 pm on Feb 23, 2013 (gmt 0)



ok thnx yall
 

Featured Threads

Hot Threads This Week

Hot Threads This Month