.htaccess:如果未在子域内访问,则重定向页面

时间:2014-08-08 05:56:06

标签: apache .htaccess subdomain

情景:

Main domain domain.com points to */home/domain/www*
Addon domain addon.com points to */home/domain/www/addon/www*

问题:如何执行以下操作:

http://addon.domain.com instead of http://domain.com/addon
http://addon.domain.com/page.html instead of http://domain.com/addon/page.html

1 个答案:

答案 0 :(得分:0)

尝试将这些规则添加到/home/domain/www目录中的htaccess文件中:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^addon/?(.*)$ http://addon.domain.com/$1 [L,R=301]