Reputation: 662
I have this url:
http://www.site.com/en/about.php?id=112&name=andrew marshall dickens
and i would like to rewrite it like this:
http://www.site.com/112/andrew-marshall-dickens.html
so far:
RewriteRule ^([^/]*)/([^/]*)\.html$ /en/about.php?id=$1&name=$2 [L]
I'm having trouble with the '-' character.Any suggestions ? Thanks!
Upvotes: 0
Views: 300
Reputation: 3023
Well you're attempting to use a Regex to remove characters from the middle of a string which could have any number of that character in it in the middle of a RewriteRule. On one hand that's not really possible, on the other hand, you're passing the ID in, so I assume you can get the name using the id in your PHP script, so there's not really a need to parse the name from the URL variables, and as a 3rd option, why not just str_replace the - characters in PHP and ucwords() the string before outputting it if you want to use the name variable?
Upvotes: 1
Reputation: 48141
I believe you don't need to pass name param because id can get that.
Anyway:
RewriteRule ^([0-9]+)/([a-z-]+)\.html$ /en/about.php?id=$1&name=$2 [L]
But hey, reading the comment, i just realized: what's your problem? Your regex should already work
Upvotes: 0