Forum Moderators: open
www.example.co.uk/used/car/used/chevrolet
www.example.co.uk/used/car.asp?used=chevrolet
***************************************************************
RewriteEngine on
RewriteRule ^/used/car/used/?([^/]*)$ /used/car.asp?used=$1 [L]
****************************************************************
The URL rewrite works fine because:
****************************************************************
RewriteEngine on
RewriteRule ^(.*?\.asp)/([^/]*)/([^/]*)(/.+)? $1$4?$2=$3 [NC,LP,QSA]
****************************************************************
works fine, but I have to leave the .asp in the URL like this
www.example.co.uk/used/car.asp/used/chevrolet
I am trying to shift the .asp and be able to modify my own rules.
Thanks for any help
Richard
[edited by: coopster at 1:49 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]
However, if this is also the case with ISAPI Rewrite, then your original rule works because it matches "^(.*?\.asp)" at the beginning of the requested URL-path, so it doesn't care if there is a leading slash or not.
Also, what is the "/?" following "used/cars/used" for? This makes that trailing slash optional. That, and the following "([^/]*)$" subpattern mean that your rule will accept a blank value for "used=". It also means that the same content will be served for
example.co.uk/used/car/used/
and
example.co.uk/used/car/used
and for
example.co.uk/used/car/used/chevrolet
and
example.co.uk/used/car/usedchevrolet
This creates duplicate-content problems -- the same content accessible at more than a single, canonical URL.
Is that what you intended?
If this were Apache, I'd suggest:
RewriteEngine on
#
RewriteRule [b]^us[/b]ed/car/used/([^/]*)$ /used/car.asp?used=$1 [L]
Jim
www.mydomain.co.uk/used/car.asp?used=chevrolet
to
www.mydomain.co.uk/used/car/used/chevrolet
Can this be done in the .htaccess file?
Sorry, I am new to this, and to be honest it is quite tough to get my head around - a digit in the wrong place and you get a big "Family Fortunes" NA NAAAAAA.
Thanks Guys
RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder/oldpage.asp$ http://www.example.co.uk/used/car.asp/used/%1 [L,R=301]
It does redirect, but it resolves this:
http://www.example.co.uk/used/car.asp/used/ford?make=ford
It needs to be:
http://www.example.co.uk/used/car.asp/used/ford
Thanks
[edited by: coopster at 1:48 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]
Since you are using the .htaccess method I'm going to assume that what jdMorgan is providing as examples should take care of ya.
I have done similar rewrite with ISAPI 3 and I would advise the following:
1)On the portion of your rule that has %1 change it to $1
2)On the clean url, escape the back-slash / and periods . with a forward-slash \
3) Change [L,R=301]to [R=301,L] so that it first redirects to the new url and then stops looking for a match.
4)Update to the latest release of ISAPI 3 (this version has had several updates since its first release)
So change it from this:
RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder/oldpage.asp$ http://www.example.co.uk/used/car.asp/used/%1 [L,R=301]
To this:
RewriteCond %{QUERY_STRING} ^make=(.+)$
RewriteRule ^oldfolder\/oldpage\.asp$ http://www.example.co.uk/used/car.asp/used/$1 [R=301,L]
Hope this helps!
KH
[edited by: coopster at 1:47 pm (utc) on Jan. 15, 2009]
[edit reason] please use example.com, thanks! [/edit]