Forum Moderators: phranque
I want to serve files from my root 'public_html' directory when requests are made for 'subdir.domain.com'. I will use Server Side Includes to decide what content is served from 'index.html', for example.
i.e. I don't want the hassle of putting the same files in half a dozen subdirectories just so I can have some subdomains.
e.g.: I need mod_rewrite code like this to put in 'public_html/subdir', or something cleverer:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(.*)$
RewriteRule ^(.*)$ /home/username/public_html/$1 [L]
I don't want a redirect. I want a rewrite.
This particular code gives an error. It's just an illustration.
PS: I don't have access to httpd.conf. Virtual Subdomains would also be nice, but I'd like a 'portable' solution, if I need to move servers in a hurry.
First, at the shell prompt:
ln -s /home/username/public_html/ /home/username/public_html/subdir/
This creates a symbolic link to 'public_html' in 'subdir'. It looks like there's now a directory 'subdir/public_html'
[subdir.domain.com...] can now be called by the browser, but that looks cr*ppy, so:
Then create subdir/.htaccess
... and put in it:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} .*
RewriteRule .* /public_html/$1 [L]
[subdir.domain.com...] then serves up the index page in '/home/username/public_html'
I'm off to bed.