Mobile app version of vmapp.org
Login or Join
Pierce454

: How to silently auto-load from a subdirectory, but allow internal paths to think the file is located at site root? I have files in my site root, and also files in its "Iternet_IE" directory.

@Pierce454

Posted in: #Apache #Htaccess #ModRewrite #Subdomain

I have files in my site root, and also files in its "Iternet_IE" directory. I need to:

1.) be able to call/include other files (e.g. headers or footers) from within files at either of those locations... using the same path in the include/link, etc. ... e.g. with a prefixing / in the include path, where those include files are located in the site root.

The catch is that I also need:

2.) any incoming traffic using our sharpedge. subdomain to auto-load from the Internet_IE directory - which is one level deeper than the site root (without Internet_IE being specified in the URL).

In an attempt to accomodate these 2 requirements, I have set the DocumentRoot for both the main domain and the subdomain to the site root:

I have this in httpd.conf:

[snip]
NameVirtualHost 11.22.33.44

<VirtualHost 11.22.33.44>
Options All +ExecCGI
ServerAdmin hostmaster@ourhost.com
DocumentRoot /var/www/html/ourdomain.com
ServerName ourdomain.com
ServerAlias ourdomain.com DirectoryIndex index.htm index.html index.dna
#---------------------------------
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
#---------------------------------
</VirtualHost>

<VirtualHost 11.22.33.44>
Options All +ExecCGI
ServerAdmin hostmaster@ourhost.com
DocumentRoot /var/www/html/ourdomain.com
ServerName sharpedge.ourdomain.com
DirectoryIndex index.htm index.html index.dna
#---------------------------------
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>
#---------------------------------
</VirtualHost>
[snip]


...and I am trying to use a RewriteRule in .htaccess to effectively cause traffic using the sharpedge. subdomain to auto-load from the Internet_IE directory:

this is in .htaccess (in the site root, here: /var/www/html/ourdomain.com/) :

Options -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^sharpedge.ourdomain.com$
# years ago this next line was used here, but in httpd.conf: (I don't know what it was supposed to do)
# RewriteRule ^(.+) %{HTTP_HOST} [C]
RewriteRule ^sharpedge.ourdomain.com(.*) /var/www/html/ourdomain.com/Internet_IE/ [L]
</IfModule>


..but nothing happens from the RewriteRule; it is as if the RewriteRule was not there. Why?

Or is there another/better way I can meet the 2 requirements I list at the top, above the code snips.?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Pierce454

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sue5673885

this did it:

RewriteCond %{HTTP_HOST} ^sharpedge.ourdomain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/Internet_IE/
RewriteRule ^(.*)$ /Internet_IE/ [L]


Thanks goes to: stackoverflow.com/a/11744085/530006

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme