My website has document root ~/public_html I'm trying to organize multi domain/subdomain redirection using htaccess.
Possible redirection logic: if domain/subdomain directory found - perform redirection, otherwise throw 404 Error.
Possible directory structure:
public_html/
.htaccess (main redirect router)
public_html/
domain-1/
application/
public_html/
.htaccess
public_html/
domain-2/
application/
public_html/
.htaccess
public_html/
domain-3/
application/
public_html/
.htaccess
public_html/
subdomain-1.domain-1/
application/
public_html/
.htaccess
public_html/
subdomain-2.domain-1/
application/
public_html/
.htaccess
Your help be deeply appreciated. Thanks.
your .htaccess file should have
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^subdomain.domain.in [NC]
RewriteRule ^(.*)$ http://www.hardikvyas.in/$1 [L,R=301]
RedirectMatch ^/$ /redirection directory name/
Try this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.