Reputation: 1839
I want to redirect my subdomain to its index file and main domain to its own index file.
Example
for www.example.com -> index.html
subdomain.example.com - >index.php
I have following rule for the main domain
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
www.example.com root folder is public/
while
subdomain.example.com root folder is public/folder/
Main domain redirection is working. But how to redirect subdomain.example.com to its index.php ie to public/folder/index.php ? Should there be seperate .htaccess file or common file?
Upvotes: 2
Views: 2158
Reputation: 18671
You can use in public/ .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^subdomain\. [NC]
RewriteCond %{REQUEST_URI} !^/folder/ [NC]
RewriteRule ^ folder%{REQUEST_URI} [NE,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
And in folder/ .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
Upvotes: 1