Page 1 of 1

whats wrong with this reg expression

Posted: Thu Jul 10, 2008 5:57 am
by gurjit
whats wrong with this reg expression, it does nothing

i am putting this in a .htaccess file and uploading it to the root directory. I want any link pointing to /estate-agents/<any file name>.html to redirect to /search/index.php?type=estate-agents


heres my mod rewrite condition

Code: Select all

 
RewriteEngine on
RewriteRule ^/estate-agents/(.*?).html$ /search/index.php?type=$1
 

Re: whats wrong with this reg expression

Posted: Thu Jul 10, 2008 7:01 am
by Apollo
try ^estate-agents/(.+)\.html$

That is: without the / at the beginning, (.+) instead of (.*?) and a backslash before .html (to treat the . literally)
Or (.*) if you also want to allow an empty filename (i.e. "estate-agents/.html")

Not 100% sure if the beginning / should be excluded for all webservers, you could also do ^/?estate-etc.. to be sure. That way it works either with and without.