Forum Moderators: phranque
Redirect http://sub.example.com/(nothinghere)?(anything after here) to http://sub.example.com
So in other words:
Redirect http://sub.example.com/?**** to http://sub.example.com
[edited by: jdMorgan at 3:13 am (utc) on Mar. 28, 2009]
[edit reason] example.com [/edit]
RewriteCond %{QUERY_STRING} &?id=(.*)$ [NC]
RewriteRule ^$ / [R=301,NC,L]
Do you want to redirect for all query strings, or just those with id= in them?
Is this just for the root page, or for all pages (filename part) of the site?
A redirect should contain full domain name in the target URL.
# Redirect root with non-blank query-string to root without query string
RewriteCond %{QUERY_STRING} [b].[/b]
RewriteRule ^$ http://www.example.com/[b]?[/b] [R=301,L] The reason for your error is an infinite loop when the query-string is re-appended and that matches your pattern again.
Use a question mark to clear the query string value.
This rule does not fix requests asking for index.html with query-string. Those also need to be fixed, as you should refer to your index pages without using their filename in the URL.
"Is this just for the root page, or for all pages (filename part) of the site? "
It seems from my mistake of a bad URL perminant redirect that the SE indexed many pages and they are all like this format [sub.site.com...] a bunch of stuff here some id=#### some ?action=show_user&user_id=104.
Thanks
I will play with your suggestion to see how it works out.
Thanks