Solved

Accessing directories outside of DocumentRoot using .htaccess

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

Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

687 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