1

I could sure use a little help with what I am trying to do with a RewriteRule in .htaccess: ...to causes URLs using our sharpedge. subdomain to auto-load from the Internet_IE directory - one level deeper than the site root.

I have this in httpd.conf:

[snip] NameVirtualHost 11.22.33.44 <VirtualHost 11.22.33.44> Options All +ExecCGI ServerAdmin [email protected] DocumentRoot /var/www/html/ourdomain.com ServerName ourdomain.com ServerAlias www.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 [email protected] 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 this 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}$1 [C] RewriteRule ^sharpedge\.ourdomain\.com(.*) /var/www/html/ourdomain.com/Internet_IE/$1 [L] </IfModule> 

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

I'd much appreciate any suggestions.

Edits:

  • I would've just changed the DocumentRoot to the directory I actually want to serve, but I need to be able to call (include) files from within files in that directory with a prefixing / in the include path, where those files are located in the site root. Those files are also similarly called from other files that are in the site root.

2 Answers 2

1

this did it:

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

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

0

You don't need a rewrite rule for that. Just change the DocumentRoot to the directory you actually want to serve.

3
  • Thanks Michael, I'm sorry I neglected to add a crucial point to my OP about why that does not work for me... which I just added to the end of my OP. Commented Jul 31, 2012 at 14:11
  • 1
    So don't turn on PHP safe mode. It's deprecated anyway. Commented Jul 31, 2012 at 15:33
  • This is not a PHP site. The site uses another server side scripting language where I include files like so: [include file=/fileH.inc]. That path worked on the previous host (to call the fileH.inc file, located in the site root), but on our new host: if I set httpd.conf like so: [snip] DocumentRoot /var/www/html/ourdomain.com/Internet_IE , ServerName sharpedge.ourdomain.com [snip], then include paths with a prefixing / do not look in site root, but starting from the Internet_IE/ directory. I need include paths to be with reference to site root. Commented Jul 31, 2012 at 16:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.