Solved

Accessing directories outside of DocumentRoot using .htaccess

Posted on 2006-10-30
4
789 Views
Last Modified: 2012-06-21
Hello all,

I've built a site that utilizes three different URLs, each of which point to a specific directory in my /htdocs folder (accomplished using rewrite in .htaccess).

The pages all reference files which are shared resources (such as .css files). The files exist in a /global directory adjacent to the three directories in question (which places the files within 'outside' of the docroot of each of my three sites). When I go to my URL, the page loads, but none of the shared resources load.

Alias seems to be the method for correcting this issue, but I can't seem to make it work.

Also interesting...my pages run a php include which loads variables and some shared copy that I reference in the page. The include file is also in the /global directory, but these variables and copy load into the page. Which tells me that the php is not affected, but the html is.

Below I'm pasting the rewrite command I currently use in my .htaccess file. It only references one URL as the other two are identical.

Thank you in advance for your help!

Travis

P.S. <UPDATE> I changed the links site wite to be direct and this works (obviously). It doesn't see like the most elegant solution, however.

---------------------

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/membersites/dreamhomesguaranteed/
RewriteCond %{HTTP_HOST} dreamhomesguaranteed.com$
RewriteRule ^(.*)$ membersites/dreamhomesguaranteed/$1 [L]
0
Comment
Question by:scend
4 Comments
 
LVL 15

Accepted Solution

by:
periwinkle earned 500 total points
ID: 17839318
I assume this is an Apache web server - yes?

If the DocumentRoot in the httpd.conf file is the directory above membersites (which it would have to be if you are basing your condition on it), is your global directory at the same level as membersites?

I.e. if your full DocumentRoot in the httpd.conf is /var/www and your membersites directory is located at /var/www/membersites, is the directory for globals located at /var/www/globals?  

If so, that isn't beneath your document root.  Instead, what is happening, is that the globals directory isn't being excluded from the RewriteRule, and it is being redirected to below  the memberistes/dreamhomesguaranteed directory.  

I'm not extremely well versed in mod_rewrite, but  I think if you add a RewriteCond something like:

RewriteCond %{REQUEST_URI} !^globals/(.*)$

before the Rewrite Rule, then it won't redirect if you are referencing the globals directory.

Also, are you certain that the following rule:

RewriteCond %{REQUEST_URI} !^/membersites/dreamhomesguaranteed/

is correct?  I'd think that the first slash should be omitted...
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now