This is a discussion on [subdomain redirect without breaking pre-existing relative links] Re: ?HOWTO redirect ChurchOfGod.Churches.org to www.Churches.org/ChurchOfGod within the Apache Web Server forums, part of the Web Server and Related Forums category; Possible to do a subdomain redirect by an explicit mod_alias redirect statement? Is there a way around mod_rewrite mangling (i....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Possible to do a subdomain redirect by an explicit mod_alias redirect statement? Is there a way
around mod_rewrite mangling (i.e. rewriting) the relative links in code under the subdomain folder? Attempts to accomplish an internal redirect of a subdomain http://ChurchOfGod.Churches.org to http://www.Churches.org/ChurchOfGod break relative links in the following manner: [Mon Jul 21 22:54:40 2003] [error] [client 199.199.199.199] File does not exist: /var/www/html/ChurchOfGod/css/ churches.css The rewrite (see below) works to get me to the right subdirectory, but then pathnames to relative links and includes are mangled. The actual relative link above should have been "/var/www/html/css/churches.css" and of course fixing the link for the rewrite would break them for code under www.churches.org/ChurchOfGod I'm guessing this is a common problem, but I'm missing something in my interpretation of relavant previous posts. Is a php or cgi script required (same problems likely?) or could some combination of NameVirtualHost or mod_alias handle it? > >On Fri, 18 Jul 2003 22:06:36 -0400, Jones <jones@justjones.org> wrote: >>Can you please describe a strategy for accomplishing the following? >> redirect http://ChurchOfGod.Churches.org to http:// www.Churches.org/ChurchOfGod >v >Per your hint to look at mod_rewrite to implement "User Virtual Hosts" >I was able to implement subdomains using that method, *but* I have >to duplicate the [unknown] way subdomains were implemented on another >box to accomodate someone else's code. This method resulted in an >extra subdomain name being put in all the includes and relative links, >so www.Churches.org/ChurchofGod works great, but ChurchofGod.Churches.org >gets me to the right subdirectory, but then all relative links and includes are >broken. that is: It results in includes which should look like this > >../images or ../includes > >showing up in the error_log as file not found ../ChurchOfGod/images >or ../ChurchOfGod/includes, etc. >v >Is there another way? I need to 2nd guess someone else's implementation >of subdomains. > >RewriteEngine on >RewriteCond %{HTTP_HOST} [^.]+\.churches\.org$ >RewriteRule ^(.+) %{HTTP_HOST}$1 [C] >RewriteRule ([^.]+)\.churches\.org(.*) /$1$2 > ># ># This should be changed to whatever you set DocumentRoot to. ># ><Directory "/var/www/html"> > |