Link to home
Start Free TrialLog in
Avatar of ls21gce
ls21gce

asked on

RedirectMatch on URL ?

Hi,

...can anyone give me the correct code to make a re-direct of a URL as in the following WRONG example

    Redirect permanent /do/category/Fishing?&firstRow=10 http://www.mySite.co.uk/do/category/Fishing/10

..its obvious what I want to achieve but this attemp does not actually work. I think I need a more complicate ReDirectMatch


Regards

SMc
Avatar of ravenpl
ravenpl
Flag of Poland image

You need rewrite not redirect. Redirect can't operate on query strings (the part after ? sign)
Assuming .htaccess
RewriteEngine On
RewriteCond %{QUERY_STRING} firstRow=([0-9]+)
RewriteRule ^do/category/Fishing.* /do/category/Fishing/%{1} [L]
Avatar of ls21gce
ls21gce

ASKER

Hi,

The above example didnt actually work for me. I am entering this directly into the httpd-vhosts.conf.

I have the cobbled together the following example that nearly works, but does not add the 'nn' on the end....

  RewriteCond %{QUERY_STRING} firstRow=([^&]+)
  RewriteRule ^/(do/category/.*) http://www.mysite.co.uk/$1? [R=301,L]

this correctly redirects:-
http://www.mysite.co.uk/do/category/anyCategory?&firstRow=10
to
http://www.mysite.co.uk/do/category/anyCategory

BUT I actually want it to redirect keeping just the end number....e.g.
http://www.mysite.co.uk/do/category/anyCategory/10


Regards,

SMc
Avatar of ls21gce

ASKER

Hi,

Ok, forget it,

If I modify the version I mentioned in my last post (see below) to

  RewriteCond %{QUERY_STRING} firstRow=([^&]+)
  RewriteRule ^/(do/category/.*) http://www.mysite.co.uk/$1/%1? [R=301,L]

This does exactly the correct job...


Regards,

SMc
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Of course - there should be %1 instead of ${1}
Of course - there should be %1 instead of %{1}
Avatar of ls21gce

ASKER


many thanks for your help ravenpl...


SMc