I've mod_rewrite focusing on the majority of my website. At this time I've got a search that would indicate


And I am attempting to rewrite that to


Just to really make it a bit cleaner. So here's my mod_rewrite. (You will find other rules I am just posting the one which is not working.)

RewriteRule ^search/?keyword=([^/\.]+)/?$ search.php?search=$1

After I type searching within the address bar way I would like it to be, I recieve a webpage saying its a "damaged link" (I am speculating that that's Chrome's same as a 404 error). What exactly shall we be held doing wrong? I believe that the issue is the '=' or even the '?' register the rule (part one) because after i go ahead and take ?keyword= part out, it really works. Does which make sense?

EDIT: This really is my full .htaccess code:

RewriteEngine on
RewriteRule ^$ index.php
RewriteRule ^thoughts$ archives.php 
RewriteRule ^thoughts/$ archives.php
RewriteRule ^about$ about.php 
RewriteRule ^about/$ about.php 
RewriteRule ^search/\?keyword=([^/]+)$ search.php?search=$1 
RewriteRule ^tags/([^/]+)$ tags.php?tag=$1
RewriteRule ^thoughts/([^/]+)$ post.php?title=$1 [L]

Still getting a mistake page...

RewriteRule ^search/\?keyword=([^/.]+)/?$ search.php?search=$1

The question mark character has special meaning inside a regex. You have to escape it.

Furthermore, the us dot doesn't have special meaning when in the character class you do not need to escape it (you are needing that keyword contain no forward slashes and dots).

If you want to transform:




all that you should do is:

RewriteRule ^search/$ search.php [QSA]

The QSA flag means "query string append", and passes to look.perl anything you request via GET:


You may even want to look at Apache MultiViews, which transmits every /foo request to the foo.* file it finds within the / directory, even though they are considered bad.