简体   繁体   中英

.htaccess - Very specific redirecting?

I've tried wrapping my head around this and it seems I cannot - My basic need to provide redirecting for users on my site that may have bookmarks to older locations. Example:

www.example.com/users/userprofile=122&action=edit

Needs to be:

www.example.com/users/id=122&action=edit


I've tried a variety of methods and rewrite rules, and I can't seem to come up with a solution.

Note that the action can be a variety of things - And may sometimes feature other extensions afterwards for instance:

www.example.com/users/userprofile=122&action=edit&theme=blue

Note that the use of '/users' is a rewrite rule of it's own - The real directory is "assets".

I won't bother posting what I've tried - Just half a dozen " 500 Internal Server errors ".

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteRule ^(users)/userprofile=(.+)$ /$1/id=$2 [L,NC,R=302]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM