Re: [users@httpd] Clarification on RewriteRule

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

 



On Sun, Mar 13, 2005 at 02:14:46PM +0530, Rajkumar s wrote:
> Dear sir,
>        I had set the RewriteLogLevel to '9' , But the previous rule
> haven't worked ,so i modified the rule as
> 
> <VirtualHost 203.199.200.129>
> #DocumentRoot /home/domains/whatsonchennai.com/Webdir
> ServerName www.whatsonchennai.com
> RewriteEngine on
> RewriteLog "/var/log/apache/rewrite.log"
> RewriteLogLevel 9
> RewriteRule ^/(.*) http://www.whatsonchennai.com:8080/  
> </VirtualHost>
> 
> On applying this rule the thing is getting redirected , ie when i
> enter the url "www.whatsonchennai.com" it's getting redirected
> to "www.whatsonchennai.com:8080". But again i find that the url in
> browsers address bar appears as "www.whatsonchennai.com:8080" but it
> should instead show up only "www.whatsonchennai.com".
> 
> Rewrite logs are provided below:

[snip]

(note: someone check me on this; I /think/ I have it right, but my
Proxy-fu isn't as strong as I'd like)

The RewriteLogs you have provided are for a violently different
configuration than you posted in your first email. In *this* posting,
you're issuing a 302 redirect to http://www.whatsonchennai.com:8080/
(note that lack of a [P,L] in your RewriteRule; the 'P' is required for
Proxying; RTFM at http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteRule). 
If the goal is to keep the ':8080'-style URLs from being seen by the end user,
a Proxy-style setup will be required. Note also that the above example
could be written as:

<VirtualHost 203.199.200.129>
	#DocumentRoot /home/domains/whatsonchennai.com/Webdir
	ServerName www.whatsonchennai.com
	ProxyPass / http://www.whatsonchennai.com:8080/
	ProxyPassReverse / http://www.whatsonchennai.com:8080/
</VirtualHost>

No mod_rewrite needed. =)

In your first posting, you had:

> <VirtualHost 203.199.69.181>
> ServerName rosaonline.org
> RewriteEngine On
> RewriteLog "/usr/local/apache/logs/rewrite.log"
> RewriteLogLevel 0
> ProxyPass  rotaryindia.net  http://203.199.69.181:8080/
> RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/rosaonline.org:80/ROSA/VirtualHostRoot/$1 [P,L]
> </VirtualHost>

This does two things:

1) Any request like this:
    GET rotaryindia.net HTTP/1.0
    Host: rosaonline.org

...would get proxyed to http://203.199.69.181:8080/. The user would see
whatever they had typed into their browser, Apache would make an
outbound HTTP request to http://203.199.69.181:8080/, and return the
contents of that request. Note that anything in the request path after
'rotaryindia.net' would get mapped to the target URL, so:

    GET rotaryindia.net/foo/bar/baz.html HTTP/1.0
    Host: rosaonline.org

...would result in Apache fetching the content from
http://203.199.69.181:8080/foo/bar/baz.html.


2) The RewriteRule portion doesn't do anything all that fancy; it simply
Rewrites any request to an outbound request to 127.0.0.1:8080, so that a
request which looks like this:

GET /foo/bar/baz.html HTTP/1.0
Host: rosaonline.org

...becomes a Proxy request to
http://127.0.0.1:8080/VirtualHostBase/http/rosaonline.org:80/ROSA/VirtualHostRoot/foo/bar/baz.html

--n

---------------------------------------------------------------------
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