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
/public/
/public/de/
/public/es/
/public/it/
/public/www/index.php
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
</IfModule>
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.
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:
Are you able to do that?
You wrote:
Maybe the problem is about your DNS configuration.
My own DNS configuration is something like:
This means "if you type
papdevis.fr
or whatever behind i.e.www.papdevis.fr
orolivier.papdevis.fr
go to the server at the adress123.123.123.123
.If I change the adress
123.123.123.123
to a new one for example234.234.234.234
, this will work and as soon as you'll typepapdevis.fr
or any other stuff (like explained before) it will go to234.234.234.234
. Everything will work smoothlessly without touching any.htaccess
file.So try to apply the same DNS configuration on your site.