Maybe some guys can help.
I was trying VirtualDocumentRoot in Apache.
Reason: Dynamic creation of folders for third level domain.
Say, some.net:
I have this folder structure in public folder
net
>some
>>www
>>another_subdomain
all .net tld goes to public/net
some.net goes to public/net/some
http://www.some.net goes to public/net/some/www
My apache virtualhost declarations
ServerName some.net
ServerAlias *.some.net
VirtualDocumentRoot /home/user/public/%-1/%-2/%-3+
<Directory /home/user/public>
</Directory>
Above works as expected except for some.net which ends up using the default rule. I'm able to fix that by adding .htaccess
RewriteCond %{HTTP_HOST} ^some\.net$ [NC]
RewriteRule . [url=http://www.some.net%{REQUEST_URI}]http://www.some.net%{REQUEST_URI}[/url] [QSA,L,R=301]
By using above, I'm just forcing some.net to use http://www.some.net which all works ok.
Is there a better way to do it?
THanks for your help.
In this setup requests for some.net will end up in /public/net/some, so you need a .htaccess there that will rewrite to the index.php that is in www/public/index.php (I presume).
I avoided these issues by using a flat structure, and define it like so:
VirtualDocumentRoot /home/user/public/%0. so I have seperate directories for http://www.some.net and http://some.net, which I would just symlink to http://www.some.net to serve the same application.
You know that if you are using mod_vhost_alias, you don't have a valid DOCUMENT_ROOT set in your $_SERVER array?
You can remedy that by using "php_admin_value auto_prepend_file", and call a script that sets it.
My contains
Thank you for replying.
I'm still learning more Apache since I would like to end up web serving some time from now.
I just learned the mod_vhost_alias consequence from you, so thanks again.