Solved

RedirectMatch on URL ?

Posted on 2006-11-18
7
221 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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hosting a website using port 443 SSL CA using Wampserver 2 How to: 6 72
Guacamole and browser performance 1 125
Problem with .htaccess file 4 73
Apache LDAP Authentication 20 53
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 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