Solved

Accessing directories outside of DocumentRoot using .htaccess

Posted on 2006-10-30
4
813 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Suggested Courses

738 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