[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Accessing directories outside of DocumentRoot using .htaccess

Posted on 2006-10-30
4
Medium Priority
?
820 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

656 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