sábado, 15 de agosto de 2009

Multiple WebSistes on Cheap GoDaddy's Plan

You are an economy plan user from GoDaddy, but it says you can only host one website....
Here you will learn how to host more than one website, without having to use lame folder redirects...
Create a .htaccess file on root
Options FollowSymLinks
rewriteEngine on
rewriteCond %{HTTP_HOST} ^www\.domainA\.com$ [NC]
rewriteCond %{REQUEST_FILENAME} !-f
rewriteCond %{REQUEST_FILENAME} !-d
rewriteRule / /folderwherefilesare/index.html [L]

rewriteCond %{HTTP_HOST} ^www\.domainA\.com$ [NC]
rewriteCond %{REQUEST_FILENAME} !-f
rewriteCond %{REQUEST_FILENAME} !-d
rewriteRule ^(.*) /folderwherefilesare/$1 [L]

rewriteCond %{HTTP_HOST} ^domainA\.com$ [NC]
rewriteCond %{REQUEST_FILENAME} !-f
rewriteCond %{REQUEST_FILENAME} !-d
rewriteRule / /folderwherefilesare/index.html [L]

rewriteCond %{HTTP_HOST} ^domainA\.com$ [NC]
rewriteCond %{REQUEST_FILENAME} !-f
rewriteCond %{REQUEST_FILENAME} !-d
rewriteRule ^(.*) /folderwherefilesare/$1 [L]
For another domain, just repeat all lines, changing what is needed...
But beware that PHP Scripts that relies on PHP_SELF, will see, and show the real address, try to place thoose on real folders on root...

PS: There's a bug with access without trailing slashes... It redirects to the real path, not the fake one... I'm still not able to fix it easily, only with a manual code:
rewriteCond %{HTTP_HOST} domainA\.com$ [NC]
rewriteCond %{REQUEST_FILENAME} (.+)[^/]$
rewriteCond %{REQUEST_FILENAME} !-f
rewriteCond %{REQUEST_FILENAME} !-d
rewriteCond /var/chroot/home/content/html/folder/ -d
rewriteRule ^(folder)$ /$1/ [L,R,NC]
Yet this is not an elegant solution, i'm looking for a better code...

Tradução para perdidos:
Como usar o mod_rewrite para redirecionar vários domínios em pastas diferentes no apache.

Nenhum comentário: