简体   繁体   中英

Rewriting urls with mod_rewrite - GET variables

I found out I could make clean urls with mod_rewrite. I managed to make pages like /home.php viewable by visiting /home (without .php).

Now, I'd like to turn view_album.php?album_id=23 into album/23

This is the code I use, but sadly it's not working:

Options SymLinksIfOwnerMatch MultiViews
RewriteEngine On
RewriteBase /beta/
RewriteRule ^album/(.*)/ view_album.php?album_id=$1

Thanks in advance.

use

RewriteEngine On
RewriteBase /beta/
RewriteRule ^album/([0-9]*)$ view_album.php?album_id=$1

and make sure you only rewrite if a noting or a number follows album/ , so your can access your images, which may be in a folder named album.

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