开发者

Show domain/sub-dirictory1 on sub-domain1.domain (.htaccess)

I want to use subdomains instead of subfolders. Unfortunately, since my host doesn't allow wildcard subdomains in my dns settings, I couldn't do a subdomain install. I do however think that I should be able to achieve this post-install, since I can manually make subdomains.

I have now made two subdomains: Subdom1 and Subdom2. My set-up at this point is domain/Subdir1 and domain/Subdir2. I'd like to have my visitors (and ideally also Google) to visit my site as subdom1.domain.com and subdom2.domain.com, both should show what is in the two s开发者_运维百科ubdirs.

I think this should be possible with .htaccess rules, but I'm hardly the expert at that. I'm hoping someone could help me with this.


try this, obviously replace blog with your subdomain name

Options -Indexes +FollowSymLinks

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

RedirectMatch 301 ^/blog/(.*)$ http://blog.example.com/$1

more here http://terriswallow.com/weblog/2008/htaccess-redirect-a-directory-to-a-subdomain-and-force-www/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜