htaccess rewrite for query string [closed]

Tag: .htaccess Author: jx2153183 Date: 2009-07-19

Ok, im pretty new at this and I would really appreciate some help, thanks!

How can i rewrite this in .htaccess correctly?

So I have a query string in my url:


All i want to do is remove the query string


Help? I scoured google and I'm learning the syntax right now, but the fact remains..I dont know how to do it just yet. Thanks to all

Other Answer1

Try this:

RewriteEngine On
RewriteRule ^(.*)$ /index.php?url=$1 [L]

To a user on your site, they will see and navigate to this:

But the real page would be something like this:

This bit, [L], tells the server that this is the last line of the rewrite rule and to stop.

Other Answer2

This was my solution:

RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]

Other Answer3

RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule index.html  %1

(or whatever if it's not index.html, index.php, whatever)

You need to capture the query string, which is not looked at by RewriteRule normally, and use the %1 back reference, not $1 as you would in a capture in a RewriteRule