Have tried a lot of examples here in SO but none seem to work. Consider my set up:
/public_html/
/app/
/cgi-bin/
/lib/
/plugins/
/revamp/
/vendors/
I currently have a cakephp website site.com
that has its files under /app/
folder, and the .htaccess I use right now looks like this:
<IfModule mod_rewrite.c>
RewriteEngine on
ReWriteRule ^$ app/webroot/ [L]
ReWriteRule (.*) app/webroot/$1 [L]
</IfModule>
I want to redirect the subdomain revamp.site.com
to the folder /revamp/
which would be another cakephp site.
UPDATE 1:
Been asked to create a vhost and i did, it is set to the subdomain folder, the help I want is for a htaccess rule to work for both, the one above and also redirect to subdomain if the requested address has the subdomain on it before the domain...
UPDATE 2:
The following .htaccess
gets me to my subdomain, but only to the index.html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site\.com$
RewriteRule (.*) app/webroot/$1 [L]
RewriteCond %{HTTP_HOST} ^revamp\.site\.com$
RewriteRule (.*) revamp/index.html [L]
</IfModule>
Its a mix of the two answers...though whatever path I put with subdomain, it only will get me to index.html (as it is hardcoded in the htaccess). Tried also revamp/$
and revamp/$1
with no luck.
UPDATE 3:
Tried this with edit of first answer:
<IfModule mod_rewrite.c>
RewriteEngine on
#subdomain simple site
RewriteCond %{HTTP_HOST} ^subdomain\.test\.com$
RewriteCond %{REQUEST_URI} !^/subdomain
RewriteRule ^(.*)$ subdomain/$1 [L]
#cakephp site
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Still gives a 500, I also tried switching positions of both blocks
Update 4:
WORKING solution, having both cakephp sites under /public_html/app
and /public_html/revamp/app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^revamp\.site\.com$
RewriteRule ^(.*)$ revamp/app/webroot/$1 [NC,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [NC,L]
</IfModule>