Forum Moderators: phranque
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
However when I check it in an http header checker it shows the following:
#1 Server Response: http://example.com/?
HTTP Status Code: HTTP/1.1 301 Moved Permanently
Date: Thu, 11 Oct 2007 16:46:10 GMT
Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.1 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a
Location: http://www.example.com/?
Connection: close
Content-Type: text/html; charset=iso-8859-1
Redirect Target: [aexample.com...]
#2 Server Response: http://www.example.com/?
HTTP Status Code: HTTP/1.1 200 OK
Date: Thu, 11 Oct 2007 16:46:10 GMT
Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.4.1 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a
Connection: close
Content-Type: text/html
X-Pad: avoid browser bug
Is this the correct response, i.e., to not remove the "?"?
One way to catch it is this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^?]+\?
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
THE_REQUEST is the entire request header received from the client, for example:
GET /page.html?foo=bar HTTP/1.1
Jim
Maybe I had better clarify. I already had this up to make sure index.html is redirected to the root:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.htm\ HTTP/
RewriteRule ^(.*)index\.htm$ http://www.example.com/$1 [R=301,L]
Should I add the rule you just posted below this one or should they both be incorporated into one?
[edited by: Lorel at 7:32 pm (utc) on Oct. 11, 2007]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^?[b]]*\[/b]?
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
Jim