Forum Moderators: phranque
I've implemented the following code on my site:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /teddy-bear\.php\?id=(.*)&make=(.*)&model=(.*)
RewriteRule ^teddy-bear\.php$ [xyz.co.uk...] [R=301,L]
But it causes the final URL to appear as
[xyz.co.uk...]
If I use a specific page it is ok but when I use (.*) or other regex it adds "%20HTTP/1.1" to the URL - can anyone tell me what's wrong with the code.
TIA
[xyz.co.uk...]
RewriteCond %{QUERY_STRING} id=([^&]*)&make=([^&]*)&model=([^&]*)
RewriteRule ^teddy-bear\.php$ /teddy-bears/%1/%2/%3\.html? [R=301] ;)
".*" is the easiest pattern to use, but it causes a lot of problems. It will match as many characters as it possibly can, and that is what is causing this problem.
I'd suggest adding a space to the character group, to exclude spaces as well. As in, "&model=([^& ]*)"
Welcome to WebmasterWorld, webdevfv2!
Jim
[added] See our forum charter (link at upper left) for a link to a short regular-expressions tutorial. [/added]
My original URL didn't have a space at the end so I'm not sure where it's picking it up from.
Like I say, if I replace each individual URL it works fine - only when I use the regex do the problems occur. Too many URLs in this instance to wish to do individual replaces although I suppose I could do as a last resort.