Forum Moderators: phranque

Message Too Old, No Replies

Subdomain mod rewrite to alternate path

mod_rewrite from subdomain to different path

         

ensteve

6:44 am on Aug 15, 2008 (gmt 0)

10+ Year Member



Hi,

I have virtual sub domains setup on my host which are configured using the following format

/path/public/www/ -> www.domain.com
/path/public/new/ -> new.domain.com

Furthermore, the scripts that power the website are controlled using a number of mod_rewrites from the "www" folder.

When using mod rewrites on new.domain.com, is it possible to define the physical path apache looks in to perform the rewrite and not default the location of the htaccess file.

for example:
new.domain.com/rewrite/

can be rewritten to:

/path/public/www/scripts/rewrite.php

Thanks in advance.
Steve

jdMorgan

1:23 pm on Aug 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would depend on a number of factors.

First, if you have access to httpd.conf, conf.d, or any of the other possible server-level config files, you can modify them to do this.

Second, if all subdomains are handled or 'routed' to their respective subfolders by code located in /path/public/www/.htaccess, then you can modify that file to do this.

However, if you have no server-config access privileges, and used a 'control panel' to 'define' your subdomains, then things get a bit more difficult (the control panel modifies the server config files for you, but in an inflexible, pre-coded-template manner). You might be able to add operating-system-level symbolic links from /path/public/new to the scripts in /path/public/www to make those scripts 'appear' to also exist in /new, but this often brings in a few problems with the scripts' execution and file-access privileges.

So, the answer is, yes, it can be done, but it depends on exactly how your server is configured. Dedicated hosting, VPS hosting, and hosting setups using IP-based virtual servers (having a dedicated, unique IP address, as opposed to the more-common shared-IP-address name-based virtual servers) generally make this easier.

There may be other ways to accomplishing your goal, so if this answer causes you to conclude that you're at a dead-end, you may want to back up a step (or even more than one step) and ask about how to accomplish your overall high-level goal, rather than focusing on asking about a specific implementation such as this.

Jim