Apache’s mod_rewrite is a whole universe of complexity of and to itself.

Suppose I have a URL that I want to redirect elsewhere:

http://www.ozymo.com/~chuck/home/tester.php?name=chuck&date=today

This PHP script doesn’t even exist on the server. This one does:

http://www.ozymo.com/~chuck/projects/mod/redird.html

So, I configure Apache to allow me to issue mod_rewrite directives in a
.htaccess file for that directory:


AllowOverride FileInfo

I bounce Apache, and put the following rewrite rules into a .htaccess file:

$ cat .htaccess
RewriteEngine on
#RewriteCond %{REQUEST_URI} ^/tester\.php$ [NC]
RewriteCond %{QUERY_STRING} ^name=chuck&date=today$
RewriteRule ^(.*)$ http://www.ozymo.com/~chuck/projects/mod/redird.html
[L,R=301]

As such, I am redirected here:

http://www.ozymo.com/~chuck/projects/mod/redird.html?name=chuck&date=today

I do not want that. I want to remove the query string from the URL. How
am I to do that? Good question, and the question gives us our answer:

I append a question mark to the end of the Substitution:

RewriteRule ^(.*)$ http://www.ozymo.com/~chuck/projects/mod/redird.html?
[L,R=301]

And voila, I’ve been redirected to the html page without an appended query
string. What a pain, that little question mark is!

/cs