You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by pe...@aol.co.uk on 2007/08/10 11:52:46 UTC

Help me with an url rewrite

I'm not sure if I've asked the correct lists,but hope I can get some 
helps here.:)

I need a mod_rewrite rule,rewrite this url:
http://abc.site.com/index.php?q1=v1
to:
http://www.site.com/index.php?q1=v1&domain=abc

I applicated this rule:

    RewriteEngine on
    RewriteRule   ^/(.+)$  http://www.site.com/$1&domain=abc


But I'm faint I can't get the correct result,it rewrote the url to:

http://www.site.com/index.php&domain=abc?q1=v1

(not http://www.site.com/index.php?q1=v1&domain=abc)

This disorder the things,I do hate it.

Can you show me a correct way?thanks.
________________________________________________________________________
Check out the new free AOL Email -- 2GB of storage and industry-leading 
spam and email virus protection.

Re: Help me with an url rewrite

Posted by pe...@aol.co.uk.
Thank you.it works perfectly.

-----Original Message-----
From: NilsKaiser@gmx.net
To: pennyyh@aol.co.uk
CC: beginners@perl.org; modperl@perl.apache.org
Sent: Fri, 10 Aug 2007 6.16PM
Subject: Re: Help me with an url rewrite

  Hello,

 well this is more of a mod_rewrite question.

  The problem is that you have to use the QUERY_STRING variable in order 
to access parameters, these are not part of the normal scope of the 
RewriteCond / RewriteRule stuff. Refer to the mod_rewrite guide for 
that.

 We use this to append a user ID to the request:

 RewriteCond %{QUERY_STRING} .
 RewriteCond %{QUERY_STRING} !^userid=
 RewriteRule ^/.* /our_server/?userid=user32&%{QUERY_STRING} [R,L]

 So in your case you should try (untested)

 RewriteEngine on
 RewriteRule ^/(.+)$ http://www.site.com/%{QUERY_STRING}&domain=abc

 Hope this helps.

 Nils

 pennyyh@aol.co.uk schrieb:
  > I'm not sure if I've asked the correct lists,but hope I can get some 
> helps here.:)
 >
 > I need a mod_rewrite rule,rewrite this url:
 > http://abc.site.com/index.php?q1=v1
 > to:
 > http://www.site.com/index.php?q1=v1&domain=abc
 >
 > I applicated this rule:
 >
 > RewriteEngine on
 > RewriteRule ^/(.+)$ http://www.site.com/$1&domain=abc
 >
 >
 > But I'm faint I can't get the correct result,it rewrote the url to:
 >
 > http://www.site.com/index.php&domain=abc?q1=v1
 >
 > (not http://www.site.com/index.php?q1=v1&domain=abc)
 >
 > This disorder the things,I do hate it.
 >
 > Can you show me a correct way?thanks.
  > 
________________________________________________________________________ 

  > Check out the new free AOL Email -- 2GB of storage and > 
industry-leading spam and email virus protection.
 >



________________________________________________________________________
Check out the new free AOL Email -- 2GB of storage and industry-leading 
spam and email virus protection.

Re: Help me with an url rewrite

Posted by Nils Kaiser <Ni...@gmx.net>.
Hello,

well this is more of a mod_rewrite question.

The problem is that you have to use the QUERY_STRING variable in order 
to access parameters, these are not part of the normal scope of the 
RewriteCond / RewriteRule stuff. Refer to the mod_rewrite guide for that.

We use this to append a user ID to the request:

    RewriteCond %{QUERY_STRING} .
    RewriteCond %{QUERY_STRING} !^userid=
    RewriteRule ^/.* /our_server/?userid=user32&%{QUERY_STRING} [R,L]

So in your case you should try (untested)

   RewriteEngine on
   RewriteRule   ^/(.+)$  http://www.site.com/%{QUERY_STRING}&domain=abc

Hope this helps.

Nils

pennyyh@aol.co.uk schrieb:
> I'm not sure if I've asked the correct lists,but hope I can get some 
> helps here.:)
>
> I need a mod_rewrite rule,rewrite this url:
> http://abc.site.com/index.php?q1=v1
> to:
> http://www.site.com/index.php?q1=v1&domain=abc
>
> I applicated this rule:
>
>    RewriteEngine on
>    RewriteRule   ^/(.+)$  http://www.site.com/$1&domain=abc
>
>
> But I'm faint I can't get the correct result,it rewrote the url to:
>
> http://www.site.com/index.php&domain=abc?q1=v1
>
> (not http://www.site.com/index.php?q1=v1&domain=abc)
>
> This disorder the things,I do hate it.
>
> Can you show me a correct way?thanks.
> ________________________________________________________________________
> Check out the new free AOL Email -- 2GB of storage and 
> industry-leading spam and email virus protection.
>