apache - .htaccess rewrite rule for replace space with hyphen in a url -
mysite.com/details/42/site title or mysite.com/details/42/site%20title
the following rewrite rule generates above url
rewriteengine on rewriterule ^details/([0-9]+)/?([a-za-z0-9_-\s]+)/?$ /detail.php?id1=$1&id2=$2
how can change url
mysite.com/details/42/site-title
how can replace spaces hiphen(-) in url, please help
assuming never have hyphens in "site title", can add this:
rewritecond %{query_string} ^(.*)&id2=([^&]+)(%20|\+)(.+)$ rewriterule ^detail.php$ /detail.php?%1&id2=%2-%4 [l]
Comments
Post a Comment