: Problem with my subdomain with .htaccess root as subdir I am working on a site making my subdir to appear as root just like //domain.com/ is //domain.com/subdir and also access/load files hiding
I am working on a site making my subdir to appear as root just like
//domain.com/ is //domain.com/subdir and also access/load files hiding the subdir. My site have this .htaccess(below) and its working. My problem is when I add a subdomain like //admin.domain.com which is //domain.com/subdir/admin my .htaccess redirect me to the main domain //domain.com
Options -Indexes
RewriteEngine on
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
Options +SymLinksIfOwnerMatch
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule .* domain.com/ [L,R=301]
RewriteRule ^$ domain/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/domain%{REQUEST_URI} -f
RewriteRule .* domain/[CO] [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* domain/index.php?rp=[CO] [QSA]
More posts by @Bryan171
1 Comments
Sorted by latest first Latest Oldest Best
I think you'll need to do something along these lines:
Options -Indexes
RewriteEngine on
RewriteBase /
Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
#Match admin.domain.com default page
RewriteCond %{HTTP_HOST} ^admin.domain.com$ [NC]
RewriteRule ^$ domain/admin/index.html [L]
#Match files that exist in domain/admin/
RewriteCond %{HTTP_HOST} ^admin.domain.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}domain/admin/%{REQUEST_URI} -f
RewriteRule .* domain/admin/[CO] [L]
#Match non-exisiting files in domain/admin
RewriteCond %{HTTP_HOST} !^admin.domain.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* domain/admin/index.html?rp=[CO] [QSA]
#Redirect anything that's not domain.com or admin.domain.com to domain.com
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteCond %{HTTP_HOST} !^admin.domain.com$ [NC]
RewriteRule .* domain.com/ [L,R=301]
#Match domain.com default page
RewriteRule ^$ domain/index.html [L]
#Match files that exist in domain/
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}domain%{REQUEST_URI} -f
RewriteRule .* domain/[CO] [L]
#Match non-exisiting files in domain
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* domain/index.html?rp=[CO] [QSA]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.