You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Aman Raheja <ar...@techquotes.com> on 2004/09/24 21:44:41 UTC

[users@httpd] RewriteRule question

I have the following

-----------<snip>-------------
RewriteEngine on
RewriteLog    logs\rewrite.log
RewriteLogLevel    9
RewriteRule   ^/a/(.+) http://httpd.apache.org/$1 [R]
---------</snip>----------------

So when I access
http://localhost/a/docs/misc/rewriteguide.html
it goes to
http://httpd.apache.org/docs/misc/rewriteguide.html

Now if I do the following

-----------<snip>-------------
RewriteEngine on
RewriteLog    logs\rewrite.log
RewriteLogLevel    9
RewriteRule   ^/a\?(.+) http://httpd.apache.org/$1 [R]
---------</snip>----------------

So when I access
http://localhost/a?docs/misc/rewriteguide.html
it gives me Error 404

Here's the rewrite.log
127.0.0.1 - - [24/Sep/2004:14:21:03 -0500] 
[test.techquotes.com/sid#5b6148][rid#66bce0/initial] (2) init rewrite 
engine with requested uri /a
127.0.0.1 - - [24/Sep/2004:14:21:03 -0500] 
[test.techquotes.com/sid#5b6148][rid#66bce0/initial] (3) applying 
pattern '^/a\?(.+)' to uri '/a'
127.0.0.1 - - [24/Sep/2004:14:21:03 -0500] 
[test.techquotes.com/sid#5b6148][rid#66bce0/initial] (1) pass through /a

According to the second line the pattern is only applied to /a and not 
/a?docs/misc/rewriteguide.html
What's going on here ?

Appreciate info.
Thanks
Aman

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule question

Posted by Joshua Slive <js...@gmail.com>.
On Mon, 27 Sep 2004 10:02:39 -0500, Aman Raheja <ar...@techquotes.com> wrote:

> Well, I sure don't need to have the trailing ?docs/mod/mod_rewrite.html
> 
> What's missing?

Add a ? to the end of the RewriteRule to tell it to delete the old query string.

(Most of this is documented in the manual, by the way; however the 2.0
manual is more complete than the 1.3 one.)

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule question

Posted by Aman Raheja <ar...@techquotes.com>.
Joshua Slive wrote:

>On Fri, 24 Sep 2004 14:44:41 -0500, Aman Raheja <ar...@techquotes.com> wrote:
>
>  
>
>>RewriteRule   ^/a\?(.+) http://httpd.apache.org/$1 [R]
>>    
>>
>
>  
>
>>According to the second line the pattern is only applied to /a and not
>>/a?docs/misc/rewriteguide.html
>>What's going on here ?
>>    
>>
>
>RewriteRules do not match against the query string.  You can do
>
>RewriteCond %{QUERY_STRING} (.+)
>RewriteRule ^/a http://httpd.apache.org/%1
>
>Joshua.
>  
>
I got that.
It does redirect it to where I want. Here's the example

RewriteEngine on
RewriteLog    logs\rewrite.log
RewriteLogLevel    9
RewriteCond %{QUERY_STRING} (.+)
RewriteRule   ^/a http://httpd.apache.org/%1 [R,L]

So when I do http://localhost/a?docs/mod/mod_rewrite.html it goes to 
http://httpd.apache.org/docs/mod/mod_rewrite.html?docs/mod/mod_rewrite.html

Well, I sure don't need to have the trailing ?docs/mod/mod_rewrite.html

What's missing?
Thanks
Aman

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] RewriteRule question

Posted by Joshua Slive <js...@gmail.com>.
On Fri, 24 Sep 2004 14:44:41 -0500, Aman Raheja <ar...@techquotes.com> wrote:

> RewriteRule   ^/a\?(.+) http://httpd.apache.org/$1 [R]

> According to the second line the pattern is only applied to /a and not
> /a?docs/misc/rewriteguide.html
> What's going on here ?

RewriteRules do not match against the query string.  You can do

RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^/a http://httpd.apache.org/%1

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org