Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

TL;DR: Is there any way to have a domain's sub-directory point to a directory outside the web root using only .htaccess with no access to the server's configuration?

I have a web site that runs three country-specific copies of a CMS on a shared hosting package (Apache 2, PHP 5).

The CMS is split into two directories:

/app      <----- Non-public content, to be placed outside the web root
/htdocs   <----- Public content

I would like to have each of the three country-specific CMSes as sub-directories to the main domain:  <-- 1st copy  <-- 2nd copy  <-- 3rd copy

the obvious problem with this structure, each CMS's /app directory would need to be put into a separate location outside the web root. However, for maintenance reasons (I am passing on my projects to another company) I would like to prevent this.

The ideal solution for me would be that each copy of the CMS resides in a directory outside the web root:

/htdocs <------- public web root


thus ensuring that the app directory can't be accessed from outside.

Each CMS's public htdocs directory would be made available to the world selectively using an Alias directive:

Alias /de ../de/htdocs
Alias /ch ../ch/htdocs
Alias /at ../at/htdocs

But this is not possible from within .htaccess (I get a 500 error) where Alias directives are not possible to specify, and as far as I know, mod_rewrite directives can only specify targets inside the web root (correct?)

As far as I can see, what I want to do is impossible to do in a shared hosting environment, but I thought I'd check whether anybody here has any ideas, as it would be a huge relief for me to be able to do it this way.

I can put a .htaccess into the parent directory (one level above web root), but that doesn't seem to change anything.

I hope it's put clear enough. If it isn't, please let me know and I will clarify.

Switching away from the shared hosting is not an option, neither is asking the hosting company about relaxing the rules - they are very good at what they do, but also very strict and conservative about individual customizations.

Leaving each app directory in the web root, and blocking access to it using Deny from all or similar, is not an option either.

share|improve this question

The "Alias" directive is not allowed in .htaccess files. According to, "Alias" is only allowed in "server config, virtual host". That's why you get a 500 error when you set it in the .htaccess context.

It's helpful to review the context flag in the apache manual when you have a server error, if you're unsure of the context proper for your directive.

I think you might easily accomplish this with some symlinks, if your host allows FollowSymlinks:

/htdocs/de -> /de/htdocs
/htdocs/ch -> /ch/htdocs
/htdocs/at -> /at/htdocs
share|improve this answer
Argh, hadn't thought about symlinks at all. I'll try that. – Pekka 웃 Feb 4 '11 at 17:45
Too bad - no dice. I can create symlinks, but Apache will give me a 403 even though I have activated Options +FollowSymlinks. That must mean that either FollowSymlinks is globally deactivated, or there is some other reason why this doesn't work. Was a good shot though, +1 and thanks for reminding me that Alias doesn't work at all from within .htaccess – Pekka 웃 Feb 4 '11 at 17:57
If it's shared hosting, then this makes sense. They might have set SymLinksIfOwnerMatch, though -- are the links and destinations owned by the same user? If your host doesn't have that set -- you might ask if they would set it for you. – beans Feb 4 '11 at 18:25
I have only one FTP account created in the package and I'm uploading everything with that, so the owner should match. I'm suspecting that I'm forbidden from specifying a symlink target outside the web root somehow. – Pekka 웃 Feb 4 '11 at 20:15
Might be SeLinux stopping you using symlinks in this way :) – AliGibbs Feb 7 '11 at 12:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.