Solved

Accessing directories outside of DocumentRoot using .htaccess

Posted on 2006-10-30
4
808 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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Restrict IIS Website without Windows login 7 58
Internal DNS Zone Issue 13 80
Problem to get function 52 112
Web server settings related to keepalive 1 126
This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
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…

828 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