homepage Welcome to WebmasterWorld Guest from 54.211.235.255
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
How to REDIRECTMATCH a URL with "?ABC" at the end.
Apache question.
ThomasAJ




msg:1498490
 11:55 pm on Aug 25, 2002 (gmt 0)

I need to redirect a URL that has ?ABC at the end but the regex in my REDIRECTMATCH directive does not see the ?ABC.
I have tried many including the following:
RedirectMatch (.*)\?ABC$ $1?XYZ
RedirectMatch (.*)ABC$ $1?XYZ
RedirectMatch (.*)?ABC$ $1?XYZ
But no REDIRECTION occurs.
Any ideas?

NOTE!
1. I cannot use REWRITE as Frontpage Extensions are affected.
2. $1?XYZ is not important in this example.
3. Though a newbie at regexs my experiments work as intended UNTIL I add ?anything at the end of a URL.
4. The object of the exercise is to know when a URL has certain 'tracking' information on the end.
5. My URL in question is on many many sites throughout the web so I cannot change it.

I'll give you an example that works WITHOUT the ?ABC.

My intention is to redirect
[mysite.com...] to
[mysite.com...]

by using

RedirectMatch (.*)PageOne.htm$ $1PageTwo.htm

in the .htaccess file within the Test directory.

This works fine, 100%, I just did it now.

However if I want to redirect
[mysite.com...] to
[mysite.com...]

using

RedirectMatch (.*)PageOne.htm?ABC$ $1PageTwo?XYZ.htm

NO redirection takes place as the PageOne.htm?ABC
is not matched at the end of the string.

No matter how I fiddle with (.*)PageOne.htm?ABC$
I cannot get a match.

As I said originally this is very important for me to resolve as I have an important URL in cyberspace that I urgently need to redirect.

Thanks

Tom

 

bobriggs




msg:1498491
 12:18 am on Aug 26, 2002 (gmt 0)

Hi Tom.

This is because the ?ABC is now in your environment as the QUERY_STRING. It is not considered part of the URL in the redirect match.

If you're wanting to change the environment, you might consider a combination of redirectMatch (or mod_rewrite) and the SetEnvIf directive.

SetEnvIf:
[httpd.apache.org...]

[added]
I've tried to set QUERY_STRING to something else based on certain conditions and the server will not let me modify it. It will let me set my own variables otherwise. Sorry if this caused you to waste some time, but the bottom line is that I don't think you can change ABC to XYZ in the Query String.

ThomasAJ




msg:1498492
 12:34 am on Aug 27, 2002 (gmt 0)

Hello bobriggs

Thanks for your effort. When I started this exercise I didn't know that ?ABC is not considered part of the URL and so is not parsed.
I also did not know that it was called the QUERY_STRING.

Is it possible, in the .htaccess file to perform an IF...THEN...ELSE.

IF QUERY_STRING = "?ABC" THEN
REDIRECT

or something like that.

Tom

bobriggs




msg:1498493
 12:40 am on Aug 27, 2002 (gmt 0)

ThomasAJ:
No if.then.else stuff (there are some conditionals in mod_rewrite)

I'm a kind of a puzzle person, so I worked on this for quite a while yesterday.

AFAIK, there is only one way: mod_rewite. And then I looked up the problems with FP extensions and so I know what you mean.

I'm glad you asked, though, because I did have a couple of other questions.

Is ?ABC ALWAYS the query? or are there others?

Because this will work:

redirect /Test/PageOne.htm [Test...]

Thereby ignoring the first tracking code.

I'd have to know more about what the circumstances are.

[edited]
that should read:
redirect /Test/PageOne.htm [mysite.com...]

ThomasAJ




msg:1498494
 8:17 am on Aug 27, 2002 (gmt 0)

Thank you very much for your efforts. I really appreciate it.

The QUERY-STRING will vary.

So I need to implement different REDIRECTS depending on the QUERY-STRING without using mod_rewrite.

Tom

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved