Using mod_rewrite and query_string to remove arguments
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Using mod_rewrite and query_string to remove arguments
Hi y'all!
I just moved one of our corporate sites from an ASP.Net portal (DotNetNuke) to a php solution due to a variety of reasons, one of which is the easy URL Rewriting and the other being performance (DotNetNuke performs HORRIBLY due to its poor design requiring several hundred separate back end queries per page). Because of the way DotNetNuke works, there are multiple URL formats for each request, which while making things flexible, also (presumably) results in duplicate content penalties in various search engines. Oh that's right - I forgot while dealing with the reimplementation that the single biggest reason for dumping DNN was the duplicate content issue!
Anyway, I've worked with mod_rewrite quite a bit where enforcing canonical domains and redirecting requests to a php handler are concerned - but now I want to send a 301 Permanent Redirect response to requests for old pages to force them to drop out of search engines (right now we are returning 404 Page Not Found responses - I'd like to use 410 which is more accurate but I don't know how well googlebot, slurp, msnbot, etc. recognize the "correct" 410 removed header).
The deal is this: we are getting incoming requests from the bots in one of two formats:
First type (DNN default)
[domain]/Default.aspx?tabid=foo
And there may be additional arguments such as:
[domain]/Default.aspx?tabid=foo&argument=bar
second DNN query type
[domain]/foo/Default.aspx
And there may be additional arguments such as:
[domain]/foo/Default.aspx&argument=bar
What I would like to do is set up rules to redirect everything with a 301 header to / so I set up a rule like this:
#RewriteRule ^Default.aspx / [R=301,L]
which does not take the query into account, so a request for, say:
[domain]/Default.aspx?tabid=foo
redirects to:
[domain]/?tabid=foo
My question is this: How do I strip the query out and replace it with nothing? I've read the apache docs on mod_rewrite and all they say is that you can use QUERY_STRING to strip the query and any arguments but there is NO mention of how to use it, nor is there any example. There is plenty of example of passing the queries on to an http handler (which I've done in php sites) but this is a totally different implementation from what I can see.
Does anyone have any pointers to this? Any good documentation or howtos out there?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.