?
Solved

Directory Issue with Apache

Posted on 2009-02-10
9
Medium Priority
?
205 Views
Last Modified: 2012-05-06
I have a website that I can access by going to http://www.mysite.com/mysite/index.html.

How can I fake the server into thinking that http://www.mysite.com/mysite/index.html is acutally http://www.mysite.com/index.html, without moving any of the code.

I'm using apache.
0
Comment
Question by:crsfs
  • 5
  • 4
9 Comments
 
LVL 27

Expert Comment

by:caterham_www
ID: 23606897
You'll need a RewriteRule which rewrites your file. But be aware that relative references in your HTML source code may be broken since you're now in the root folder. Or do you like to rewrite everything to /mysite/?
#/.htaccess, i.e. in the URL-path root
RewriteEngine on
RewriteRule ^(index\.html)$ /mysite/$1 [L]

Open in new window

0
 

Author Comment

by:crsfs
ID: 23607026
It's a full site there, so we'd probably have to change all the references.  Is this rewriting each file as it's read or is it just modifying the full url?

So in the example http://www.mysite.com/mysite/level2/index.html, etc. would be accessible from http://www.mysite.com/level2/index.html.

From other things I've looked at, it looks like this may be do-able with VirtualHosts in http.conf?
0
 

Author Comment

by:crsfs
ID: 23607031
sorry apache2.conf, not http.conf.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 27

Expert Comment

by:caterham_www
ID: 23607093
> So in the example http://www.mysite.com/mysite/level2/index.html, etc. would be accessible from http://www.mysite.com/level2/index.html.

No, not yet.

Trying to figure out the best solution...:

Are there other files/folders present (e.g. /foo) which should not go into /mysite/?

> From other things I've looked at, it looks like this may be do-able with VirtualHosts in http.conf?

If you have a separate domain or subdomain, yes.

(httpd.conf is the standard name in the distribution from apache.org, other distributors have chosen to use another name)
0
 

Author Comment

by:crsfs
ID: 23607108
Yes, it ends up being kind of a deep structure.  I'd like to access everything in " /mysite/ " as if it were just in " / ".

Essentially, the application that is exposing the content, forces the extra folder, we just want that to disappear.
0
 
LVL 27

Accepted Solution

by:
caterham_www earned 2000 total points
ID: 23607193
So you can't change the DocumentRoot due to your application?

The following in your apache2.conf (outsite of <directory> etc.) will rewrite everything but mysite into /mysite/ while the path represents the full physical path.
#apache2.conf
RewriteEngine on
RewriteCond $1 !^mysite
RewriteRule ^/(.*) /var/www/mysite/$1 [L]

Open in new window

0
 

Author Comment

by:crsfs
ID: 23607217
Thanks a lot.  I'm new to Apache, and web dev in general, so I assume I'm screwing up some of the terminology.

So, going to http://www.mysite.com will show http://www.mysite.com but will be pulling files from http://www.mysite.com/mysite/  ?
0
 
LVL 27

Expert Comment

by:caterham_www
ID: 23607335
Yes, that's an internal rewrite which doesn't change REQUEST_URI but maps the request to another physical path (except if there's some error and /mysite/ was requested to prevent a mapping to /var/www/mysite/mysite/).
0
 

Author Comment

by:crsfs
ID: 23607351
Great.  Truly a genius.  Thanks for bearing with me as I learn this stuff.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 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