2015-10-22 208 views
2

我的网站有文档根〜/ public_html我试图使用htaccess组织多域/子域重定向。miltiple域名/子域名使用htaccess

可能的重定向逻辑:如果发现域/子域目录 - 执行重定向,否则抛出404错误。

可能的目录结构:

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 

你的帮助,深深赞赏。 谢谢。

+0

这就是VirtualHosts的优点。 https://httpd.apache.org/docs/2.2/en/vhosts/ – wmk

+0

不幸的是,根据我的主机限制,我无法访问apache设置。 – mosgaz

+0

是否可以使用htaccess解决我的问题? – mosgaz

回答

0

.htaccess文件应该有

RewriteEngine On 
RewriteBase/
RewriteCond %{HTTP_HOST} ^subdomain.domain.in [NC] 
RewriteRule ^(.*)$ http://www.hardikvyas.in/$1 [L,R=301] 

RedirectMatch ^/$ /redirection directory name/ 

试试这个。

+0

谢谢,Hardik Vyas!另一种方式来完成它: RewriteCond%{HTTP_HOST}^subdomain.domain.com RewriteRule ^(。*)$ http://domain.com/subdomain/$1 [L,NC,QSA] – mosgaz

+0

找到其他方法,没有.htaccess涉及http://stackoverflow.com/questions/33277100/miltiple-domain-subdomain-using-htaccess?noredirect=1#comment54383405_33277100 – mosgaz

+0

欢迎朋友.. –