使用htaccess的多域/子域

时间:2015-10-22 08:57:59

标签: php .htaccess mod-rewrite redirect

我的网站有文件root~ / public_html我尝试使用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

非常感谢您的帮助。 感谢。

1 个答案:

答案 0 :(得分: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/

试试这个。

相关问题