Solved

RedirectMatch on URL ?

Posted on 2006-11-18
7
225 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 43

Expert Comment

by:ravenpl
ID: 17972189
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
ID: 17974193
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
ID: 17974207
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
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 43

Accepted Solution

by:
ravenpl earned 250 total points
ID: 17974210
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
ID: 17974211
Of course - there should be %1 instead of ${1}
0
 
LVL 43

Expert Comment

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

Author Comment

by:ls21gce
ID: 17974572

many thanks for your help ravenpl...


SMc
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

734 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