开发者

URL rewriting: addon domains, subdomains, and directories

Say I have domain.com and addon.com. My hosting provider is Bluehost. domain.com is the primary domain (hosted in public_html) and addon.com is an addon domain (hosted in public_html/addon). I'd like to make the following redirects:

  • http://domain.com/addon/*http://addon.com/*

  • http://addon.domain.com/*http://addon.com/*

For reference, both public_html/.htaccess开发者_运维技巧 and public_html/addon/.htaccess have working rules for removing the www prefix:

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301]

How do I go about adding the other redirects in a way that will play nice with these rules?


Place these 2 rules in your public_html/.htaccess file:

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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜