RE: [users@httpd] Infinite loop with RewriteRule

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Boyle Owen wrote on 31.05.2005:

>>RewriteCond %{HTTP_HOST} (first|second|third|fourth) RewriteRule
>>^(.+)$ %1/$1 [L,R,NC]
>
>You do understand what ^(.+)$ converts to? It means: "from the
>start, 1 or more of any character (greedy), to the end"
>
>That is, it will match the entire URI, no matter what it is.
>
I do understand it. What I did miss, though, was the fact that the R flag caused a transparent redirect so the rewritten URL would enter the cycle again.

>Rather than asking for a theoretical explanation of why your pattern
>doesn't work, why not describe what you're trying to achieve and
>explain why you think you need this pattern. Eg,
>
>- what is the input URL? - what do you want the output to look like?

The problem is that I get requests for these URLs:

http://firsthost/somestring
http://secondhost/somestring
http://thirdhost/somestring

All of the hostnames are just aliases pointing to the same DocumentRoot.

So I wanted a simple rule that adds the first part of the hostname to the URL:

http://firsthost/first/somestring
http://secondhost/second/somestring
http://thirdhost/third/somestring

so the extended URLs can be matched by the following rules:

RewriteRule ^first/somestring/?$ cgi-bin/show.pl?id=1234 [L,NC]
RewriteRule ^second/somestring/?$ cgi-bin/show.pl?id=4321 [L,NC]
RewriteRule ^third/somestring/?$ cgi-bin/show.pl?id=4883 [L,NC]

I came up with

RewriteCond %{HTTP_HOST} (first|second|third)
RewriteRule ^(.+)$ %1/$1 [NC]

which works, now that I removed the R flag.

Thanks,

Jan
-- 
Lead me not into temptation. I can find it myself. - Jeffrey Kaplan

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux