Solved

RedirectMatch on URL ?

Posted on 2006-11-18
7
216 Views
Last Modified: 2010-03-04
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
0
Comment
Question by:ls21gce
  • 4
  • 3
7 Comments
 
LVL 43

Expert Comment

by:ravenpl
Comment Utility
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]
0
 

Author Comment

by:ls21gce
Comment Utility
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
0
 

Author Comment

by:ls21gce
Comment Utility
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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 43

Accepted Solution

by:
ravenpl earned 250 total points
Comment Utility
Yes, rewriting differs if used in httpd.conf and .htaccess. For httpd.conf
RewriteEngine On
RewriteCond %{QUERY_STRING} firstRow=([^&]+).*
RewriteRule ^/do/category/([^/]*).* /do/category/$1/%{1} [L] //or [L,R] if You want redirect externally
0
 
LVL 43

Expert Comment

by:ravenpl
Comment Utility
Of course - there should be %1 instead of ${1}
0
 
LVL 43

Expert Comment

by:ravenpl
Comment Utility
Of course - there should be %1 instead of %{1}
0
 

Author Comment

by:ls21gce
Comment Utility

many thanks for your help ravenpl...


SMc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now