Answer the question
In order to leave comments, you need to log in
How to redirect to a subdomain using htaccess?
Moved to another hosting. There, both the domain and the subdomain will be erased into one folder. You need to do the following using htaccess:
all requests to mysite.com go through index.php
all requests to admin.mysite.com go through admin/index.php I
am almost not familiar with htaccess, I wrote this myself (does not work):
RewriteEngine on
# hide files and folders
RedirectMatch 404 /\.git
RedirectMatch 404 /composer\.
RedirectMatch 404 /.bowerrc
RewriteCond %{HTTP_HOST} ^nationsorg\.eu$
RewriteCond %{REQUEST_URI} !^/
RewriteRule . index.php
RewriteCond %{HTTP_HOST} ^admin\.nationsorg\.eu$
RewriteCond %{REQUEST_URI} !^/admin/
RewriteRule (.*) /admin/index.php
RewriteEngine on
# hide files and folders
RedirectMatch 404 /\.git
RedirectMatch 404 /composer\.
RedirectMatch 404 /.bowerrc
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Answer the question
In order to leave comments, you need to log in
If I understand the problem correctly, then:
RewriteEngine on
# hide files and folders
RedirectMatch 404 /\.git
RedirectMatch 404 /composer\.
RedirectMatch 404 /.bowerrc
# Redirect to admin
RewriteCond %{HTTP_HOST} ^admin\.nationsorg\.eu$
RewriteRule ^(.*)$ admin/$1 [L]
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question