Using mod ReWrite to redirect request with certain parameters.

Hello;

I want to capture, and redirect, URLs that contain certain parameters (after
the ?). I have been reading a number of articles (web pages) on mod Rewrite,
but can't seem to get it working like I want.

For example, I want to redirect all URLs with "wxyz" in them, such as:

a.html?p1=123,p2=qwerty,wxyz=4
b.html?wxyz=def

Is what I want to do possible?

If so, can someone point me to an article (web page) or two that I can read?
(the pages I've found so far have not provided me the info I need.)

TIA.

Charles...
Charles Crume [ Di, 23 Oktober 2007 23:16 ] [ ID #1852298 ]

Re: Using mod ReWrite to redirect request with certain parameters.

Charles Crume wrote:
> Hello;
>
> I want to capture, and redirect, URLs that contain certain parameters (after
> the ?). I have been reading a number of articles (web pages) on mod Rewrite,
> but can't seem to get it working like I want.
>
> For example, I want to redirect all URLs with "wxyz" in them, such as:
>
> a.html?p1=123,p2=qwerty,wxyz=4
> b.html?wxyz=def
>
> Is what I want to do possible?
>
> If so, can someone point me to an article (web page) or two that I can read?
> (the pages I've found so far have not provided me the info I need.)

This can be done using mod_rewrite. The parameters after the ? are
known as the Query_string. Rewrite Rules can be written that are
conditional on query_string matching a regular expression:

RewriteCond %{QUERY_STRING} wxyz
RewriteRule (.*) <redirect URL>
Jim Hayter [ Mi, 24 Oktober 2007 00:33 ] [ ID #1852303 ]

Re: Using mod ReWrite to redirect request with certain parameters.

"Jim Hayter" <see.reply.to [at] nowhere.invalid> wrote in message
news:13hstkiev3p6b41 [at] news.supernews.com...

[snip]

>
> This can be done using mod_rewrite. The parameters after the ? are known
> as the Query_string. Rewrite Rules can be written that are conditional on
> query_string matching a regular expression:
>
> RewriteCond %{QUERY_STRING} wxyz
> RewriteRule (.*) <redirect URL>

Thanks Jim;

I went back and scanned all my articles -- and there in one of them is the
mention of using {QUERY_STRING}. Looks like I missed it while trying to
absorb all the other info.

Thanks again.

Charles...
Charles Crume [ Do, 25 Oktober 2007 05:28 ] [ ID #1854361 ]
Webserver » alt.apache.configuration » Using mod ReWrite to redirect request with certain parameters.

Vorheriges Thema: Please little help to rewrite the URL
Nächstes Thema: problem with virtual named hosts - its always the default virtual site that's loaded