Forum Moderators: phranque

Message Too Old, No Replies

Multiple ways to do the same thing - which to use? (most efficient?)

rewrite, proxypass, IfModule, Directory, htaccess?

         

leobag

10:47 pm on Nov 17, 2004 (gmt 0)

10+ Year Member



I needed a solution to 'map' a domain name to a subdirectory of a website on a different host. After some search and suggestions from this forum, I ended up with a bunch of methods to accomplish the same thing.

My main concern here is finding the best method to accomplish the task by using the least system resources (like cpu processes, or site requests, or whatever).

First I need to make the decision on whether to have these options put into the site configuration (conf file), or if I should have them in an .htaccess file.

If I were to place them in the site configuration setup, I need to know if I should use an <IfModule> or <Directory> method.

then I need to decide which extension to use. My options are using "Rewrite" or "ProxyPass."

Does anyone have suggestions on the most efficient method?

Thank you,
Leo

jdMorgan

11:50 pm on Nov 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The most efficient approach would be to point the domain name to the other server, and then define that domain as a virtual host on that server with it's root directory defined as the subfolder.

Other than that, using httpd.conf will be much more efficient than using .htaccess. The "Internal Processing - API Phases" part of the mod_rewrite documentation will explain why.

Jim

leobag

12:28 am on Nov 18, 2004 (gmt 0)

10+ Year Member



The other server is an IIS server that isn't really set up for this (also, the owners of that server wanted it configured this way).

As far as ways to implement, does it matter if I use the <IfModule> or <Directory> methods for the conf?

I think the rewrite method uses the ProxyPass, so I guess it wouldn't matter which one I used?

Rewrite method:


<Directory /home/httpd/htdocs/>
RewriteEngine on
RewriteRule ^(.*)$ http://www.domain.com/subdir/$1 [P]
</Directory>

Proxy method:


<IfModule mod_proxy.c>
ProxyPass / http://www.domain.com/subdir/
ProxyPassReverse / http://www.domain.com/subdir/
</IfModule>

jdMorgan

12:52 am on Nov 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure if either method has an advantage. However, make sure you read the entire mod_proxy document; There are definite security vulnerabilities you need to avoid. Make sure you do not set up your server as an open proxy -- this would allow anyone to use it to pass requests to any other server, and that would invite undesireable traffic.

Jim