Sirwan Rauofi
Sirwan Rauofi

Reputation: 152

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...

Upvotes: 0

Views: 99

Answers (1)

Nouman Arshad
Nouman Arshad

Reputation: 593

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

Hope, it helps you

Upvotes: 1

Related Questions