简体   繁体   中英

Hiding URL parameter with Mod-Rewrite

I am not sure if this is possible. I have the following url structure

http://www.my-domain.com/layouts/page.php?artist=artist-name&link=1234

which shows in the address bar as

http://www.my-domain.com/artists/artist-name/1234

In the .htaccesss file I have

RewriteEngine On
RewriteRule ^artists/([^/]*)/([^/]*)$ /layouts/page.php?artist=$1&link=$2 [L]

What I would like is to hide the last variable (the 1234) from showing in the address bar but still be available to process on the target page. The address bar would show

http://www.my-domain.com/artists/artist-name

If this is not possible can I save the variable (the 1234) to a cookie from the .htaccess file then remove the variable so it isn't shown in the address bar? Then I can pick it up on the target page from the cookie.

Try using (.+) . Something in this manner:

RewriteRule ^artists/artist-name/\d+-(.+) /artists/$1 [R=301]

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