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

I need to point subdomains like to /public/www/index.php
The problem is my host does NOT provide me to set a path, I can only set up the subdomains for "local use", which creates the folders in the public directory

My structure is


My host told me to use .htaccess files inside the sub domain folders.

I tried, for example in /public/es/ something like

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(de|es|it)\.mydomain\.com$
        # Create an environment variable to remember the language:
    RewriteRule (.*) - [QSA,E=LANGUAGE:%1]
        # Now check if the LANGUAGE is empty (= doesn't exist)
    RewriteCond %{ENV:LANGUAGE} !^$
        # If so, create the default language (=es):
    RewriteRule (.*) - [QSA,E=LANGUAGE:es]
        # Change the root folder of the spanish language:
    RewriteCond %{ENV:LANGUAGE} ^es$
        # Change the root folder:
    RewriteRule ^/?$ /public/www/index.php

But I am getting a 404 on this:
The requested URL /public/www/index.php was not found on this server.

In my DNS list I see that CNAME
while CNAME

I tried also assigning CNAME to
but that did not change anything.

share|improve this question
Thank you for using my answer here…, this is a great reward that what I write isn't useless ;) – Olivier Pons Mar 13 '12 at 8:28

The best way would be to change the DocumentRoot directive in your Apache config files for those sobdomains so that they all point to /public/www/ but I guess you can't do that.

I don't think there's any way to do what you are asking with a .htaccess file.

You could create a symlink instead of a folder so that:

/public/de/ -> /public/www/

Are you able to do that?

share|improve this answer
hi, no I can't. No symlinks either, I tried that allready making them with PHP's symlink() function but it doesn't work. – FFish Mar 10 '12 at 13:56
In that case, I think you might be best off going for a subdirectory such as /es/ or a query string such as ?lang=es instead of subdomains. If you want to be clever, you can use the client's Accept-Language header to choose the best language for them. – Ladadadada Mar 10 '12 at 14:28
That's what I have right now, with a ?locale=es_ES var, but I need to solution with the subdomains for SEO and Analytics. /es/ directories are too difficult to implement right now. – FFish Mar 10 '12 at 18:27

You wrote:

In my DNS list I see that CNAME while CNAME

Maybe the problem is about your DNS configuration.

My own DNS configuration is something like:

$TTL 86400
@   IN SOA (2011111300 86400 3600 3600000 86400)
            IN  NS 
            IN  NS 
            IN  A 
*           IN  CNAME 

This means "if you type or whatever behind i.e. or go to the server at the adress

If I change the adress to a new one for example, this will work and as soon as you'll type or any other stuff (like explained before) it will go to Everything will work smoothlessly without touching any .htaccess file.

So try to apply the same DNS configuration on your site.

share|improve this answer

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.