Forum Moderators: phranque

Message Too Old, No Replies

Rewrite help

REwrite Rule not working

         

avinashbandgi

10:11 am on Jul 13, 2004 (gmt 0)

10+ Year Member



Hi All,
Below are my setting in for rewrite engine. The rule mentioned below is not working what so ever. Actually the requested resource is on different machine called ab04. Http Server is on different machine. As i have turned on my rewrite log level to 9 , just to see the rule applying. Any request uri starting from business i get 404 error in access logs but nothing in rewrite log. Please help and thanks in advance

-Avinash.

RewriteEngine on
RewriteLogLevel 9
RewriteLog "/usr/Hinstall/logs/rewrite.log"

RewriteCond %{REQUEST_URI} ^/business
RewriteRule ^/(.*)$ [ab04:81...] [L]

am i doing anything obivious wrong in here.

gergoe

4:18 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



Do you have these directives in a .htaccess file or in the main server config (you did not mentioned where these settings are located)?
The use of the RewriteRule [httpd.apache.org] is that it evaluates the path and the filename part of each incomming request, so the use of the RewriteCond in your case is not neccesarry, although this should not be the reason why the rewriting is not working. Do you have the mod_rewrite enabled in the server config? Is the ab04 server connected to the internet (so it is not on some internal network)?
Anyway, try this instead of the RewriteRule and the RewriteCond, might solve your problem

RewriteRule ^/business/(.*)$ http://ab04:81/$1 [R,L]

...if not, then try to answer the questions above.

avinashbandgi

6:25 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



The above mentioned settings are located in server config file. I have enbaled the mod_rewrite module enabled in server config file. The machine ab04 is on internal network and it's reachable from the Http Server. My requirement any uri starting from business should be rewritten to [ab04:81...] by the exact uri>>.

Hope this gives all the info u required.

Thanks for ur time

gergoe

10:14 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



Then you need to enable mod_proxy in the server config because the apache needs to fetch the page from the internal server prior to serving the request (but don't forget to turn off the public proxying with the ProxyRequests directive [httpd.apache.org]).

Additionaly you need to change the RewriteRule a bit, to tell mod_rewrite that the request should be placed through mod_proxy module, to do so replace the Redirect flag with Proxy flag.

To clarify what this rule is doing; it puts all requests starting with /business/ though mod_proxy which requests the page from the internal server, for example the [domain.com...] becomes [ab04:81...] on the ab04 server.

Please ot that if your server is using any of the virtual hosting methods, then you need to place the mod_rewrite directives (at least the RewriteRule) in a <VirtualHost/> container, otherwise it might not be parsed.

avinashbandgi

11:14 am on Jul 16, 2004 (gmt 0)

10+ Year Member



Hi ,

As you said i have enbaled the proxyrequest directive as well. But the rewrite rule is not working. From this machine when i telnet to ab04:81 it's connecting and request this "/business/forms/garantierisico.html" i am getting complete html output. In the Apache logs i get "/business/forms/garantierisico.html" 404 error.

Please help, Thanks in advance.

Below are setting of virtual host.

ProxyRequests on
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/business/(.*)$
RewriteRule ^/(.*)$ [gl04:81...]
RewriteLogLevel 9
RewriteLog /usr/Hinstall/logs/rewrite-test.log