Tim Print
Tim Print

Reputation: 165

Redirecting with query string

I am trying to use htaccess to redirect urls like

/admin.php?/cp/myaccount&id=975

to

/admin.php?/cp/myaccount/edit_profile&id=975

I've been searching around a lot but not found anything that will work yet. How can just get the id number part of the query string and pass it to the redirect?

Upvotes: 1

Views: 28

Answers (1)

anubhava
anubhava

Reputation: 784958

You can use this rule in your site root .htaccess:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(.+)(?<!/edit_profile)&(id=\d+) [NC]
RewriteRule ^admin\.php$ %{REQUEST_URI}?%1/edit_profile&%2 [NC,L,R=302]

Upvotes: 1

Related Questions