Re: [users@httpd] rewriterule causing [redirect/302] error

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

 



Group, bits of this message will be redundant, a portion of the coversation was accidentally taken off-list a while back, I apologize.

I have Apache listening on port 9980. In Internet Explorer, the "use proxy server for your LAN" option is turned on. The address is 127.0.0.1 and the port is 9980. There is a local directory named 'webcontent' that Apache is serving pages out of. Here is one of the rewriteRules:

#Is the request in the local directory?
RewriteCond %{DOCUMENT_ROOT}/webcontent/%{SERVER_NAME} !-d
#No, it isn't. Request the actual Internet page
RewrteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [P]


This works fine. A working example of this would be me requesting the page 'www.math.com' in my browser. The directory 'www.math.com' exists in the local 'webcontent' directory, so that version of page would be served. Now say I request 'slashdot.org'. The directory 'slashdot.org' does not exist in the local webcontent directory, so it retrieves the actual Internet page from slashdot. My problem is occuring when I attempt to retrieve the Internet version of a page that also exists in my local 'webcontent' directory. In my local webcontent directory I have a folder, named 'www.test.com' (that simply contains a webpage saying "you have the wrong page" for testing purposes). I am using the following rewriteRule:

#See if the requested page is http://www.test.com
RewriteCond %{SERVER_NAME} www.test.com
#It is. Now see if 'www.test.com' is a folder in the webcontent/ directory
RewriteCond %{DOCUMENT_ROOT}/webcontent/%{SERVER_NAME} -d
#It is.
RewriteRule ^/(.*) http://%{SERVER_NAME}%{REQUEST_URI} [P,L]

My problem is that if I include the [P] flag, it still serves up the local version instead of retrieving
it from the Internet. If I do not include the [P] flag, I get thrown into a redirect loop with the
following repeating output:

(2) init rewrite engine with requested uri /
(3) applying pattern '^/(.*)$' to uri '/'
(4) RewriteCond: input='www.test.com' pattern=' www.test.com' => matched
(4) RewriteCond: input='C:/egranary/webcontent
/www.test.com' pattern='-d' => matched
(2) rewrite / -> http://www.test.com/
(2) implicitly forcing redirect (rc=302) with http://www.test.com/
(1) escaping http://www.test.com/ for redirect
(1) redirect to http://www.test.com/ [REDIRECT/302]

My question: How do I go about ignoring the local 'www.test.com' folder and serving the actual page from www.test.com?
--Josh Greenwood

On 10/5/05, Joshua Slive <jslive@xxxxxxxxx> wrote:
On 10/5/05, Josh Greenwood <joshgreenwood@xxxxxxxxx> wrote:
> I still get the local page when applying [P,L]. I was originally using
> [P,S=5], which skipped the
>  rest of the rewriteRules. Is it possible that I need to do something more
> custom than simply using
>  using the [P] flag?

Ugh... I accidentally took this conversation off-list a ways back in
the thread.  Sorry.  Damn google defaults.

Could you please summarize the problem and your current configuration
back to the list so everyone can help.

Joshua.


[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