Xriuk
Xriuk

Reputation: 392

htaccess RewriteRule special characters

I have this line of code:

RewriteRule ^account/?edit=([A-Za-z]+)$ /?goTo=account&act=edit_$1 [L,NC]

When I go to mysite.com/account/?edit=username it is supposed to refer to mysite.com?goTo=account&act=edit_username but it gives me error 404

Any help?
Thanks!

Upvotes: 2

Views: 832

Answers (1)

anubhava
anubhava

Reputation: 786289

You cannot match QUERY_STRING using RewriteRule. That requires a RewriteCond like this:

This should work:

RewriteCond %{QUERY_STRING} (?:^|&)edit=([^&]*) [NC]
RewriteRule ^account/?$ /?goTo=account&act=edit_%1#something [L,NC,NE,QSA]

Reference: Apache mod_rewrite Introduction

Upvotes: 2

Related Questions