I wanted to do this in a directory, infinite-something-news-23.html to /mysite/php/news_details.php?news_id=$2 and i have this placed in the .htaccess RewriteRule ^([a-z]|[0-9]|[-.]|[^/$&?=\s])*\-news-([0-9]+)\.(html|shtml|htm)$ /myportal/php/news_details.php?news_id=$2 [NC,NS,PT,L] Now the mapping works fine, BUT when i try something little invalid like infinite-something-news-2alpha3.html then the browser just hangs (FF, IE both) for infinite time and Apache load raises to 100%. I m not sure abt the flags either, tried with or without them. Didnt work. Can someone please help me with fixing the rule ? Appereciate any help. Thank you.
try this. should work pretty well. RewriteEngine on RewriteRule ^([^\s=&$\?][a-z0-9-]+(?:news-([0-9]{1,}))(?:\.s?html?))$ /myportal/php/news_details.php?news_id=$2 [L] PHP:
Works file, thanks a lot. Just added NC flag to make it case insensitive. btw, what does : (colon) means in regular expression. I mean what is its effect in this case ?
The ?: means the group (expression between parenthesis) where it's in won't be captured in a variable, like $1.