Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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 hostmaster@ourhost.com
    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 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 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.
share|improve this question

2 Answers 2

up vote 1 down vote accepted

this did it:

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

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

share|improve this answer

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

share|improve this answer
    
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. –  govinda Jul 31 '12 at 14:11
1  
So don't turn on PHP safe mode. It's deprecated anyway. –  Michael Hampton Jul 31 '12 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. –  govinda Jul 31 '12 at 16:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.