Mod Rewrite - Redirecting based on having GET parameters or not

Posted by XaviEsteve on Stack Overflow See other posts from Stack Overflow or by XaviEsteve
Published on 2010-05-14T14:56:49Z Indexed on 2010/05/14 15:04 UTC
Read the original article Hit count: 224

Filed under:
|

I want to redirect these URLs:

http://example.com/search to http://example.com/?page=search

http://example.com/search?q=keyword to http://example.com/?page=search&q=keyword

I am trying to use this in .htaccess but doesn't work:

RewriteRule ^search$ ?page=search [nc]
RewriteRule ^search\?(.*)$ ?page=search&$1 [nc]

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about apache

Related posts about mod-rewrite