简体   繁体   中英

making regular expression for rewrite url with 2 parameter in the .htaccess file

i have to pass 2 parameter to a page and rewrite my url with following regular expression in the .htaccess file:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^chart/(.*)$ ./charts.php?id=$1&name=$2

means,for example when url is: chart/part1/part2/ i want to load: charts.php?id=part1&name=part2 instead of that. i know this regular expression that i used is wrong. what regex i should write instead this?

^chart/(.*)$

what's the correct regex for this? thanks...

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^chart/([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ charts.php?id=$1&name=$2 [L]

Hope, it helps you

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