Link to home
Start Free TrialLog in
Avatar of crsfs
crsfs

asked on

Directory Issue with Apache

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.
Avatar of caterham_www
caterham_www
Flag of Germany image

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

Avatar of crsfs
crsfs

ASKER

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?
Avatar of crsfs

ASKER

sorry apache2.conf, not http.conf.
> 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)
Avatar of crsfs

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crsfs

ASKER

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/  ?
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/).
Avatar of crsfs

ASKER

Great.  Truly a genius.  Thanks for bearing with me as I learn this stuff.