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 FollowSymLinksFor another domain, just repeat all lines, changing what is needed...
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]
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]Yet this is not an elegant solution, i'm looking for a better code...
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]
Tradução para perdidos:
Como usar o mod_rewrite para redirecionar vários domínios em pastas diferentes no apache.
Nenhum comentário:
Postar um comentário