Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to point subdomains like es.domain.com 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
es.domain.com CNAME onlinux-it.setupdns.net
while www.domain.com CNAME domain.com

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

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

2 Answers 2

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
add comment

You wrote:

In my DNS list I see that es.domain.com CNAME onlinux-it.setupdns.net while www.domain.com CNAME domain.com

Maybe the problem is about your DNS configuration.

My own DNS configuration is something like:

$TTL 86400
@   IN SOA dnsxx.ovh.net. tech.ovh.net. (2011111300 86400 3600 3600000 86400)
            IN  NS     dnsxx.ovh.net. 
            IN  NS     nsxx.ovh.net. 
            IN  A 
*           IN  CNAME  papdevis.fr. 

This means "if you type papdevis.fr or whatever behind i.e. www.papdevis.fr or olivier.papdevis.fr 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 papdevis.fr 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
add comment

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.