Solved

RedirectMatch on URL ?

Posted on 2006-11-18
7
231 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

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…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

630 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