您的位置:首页 > 运维架构 > Linux

Linux下利用.htaccess建立多站点

2011-08-02 11:01 295 查看
一、登录域名注册商进行你的域名管理,设置A记录,A (Address) 记录是用来指定主机名(或域名)对应的IP地址记录。或者设置别名记录,CNAME (Canonical Name)记录,它可以将你注册的不同域名统统转到一个主域名上去!与A记录不同的是,CNAME别名记录设置的可以是一个域名的描述而不一定是IP地址!

二、编写文本文件htaccess进行规则重写。

原文出自 http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=394

你把它拷贝下来后,请你从你主机public_html目录下下载你自己的文件后用记事本打开进行编辑。下面是我翻译的结果,你对照进行修改。

#开头的语句是注释,被apache服务器忽略。

# Do not change this line.
#不要修改下面这行

RewriteEngine on

# Change yourdomain.com to be your main domain.
#把下面的yourdomain.com 修改为你自己的主域名

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$

# Change ’subfolder’ to be the folder you will use for your main domain.
#把下面的’subfolder’修改为你在主机上的子目录

RewriteCond %{REQUEST_URI} !^/subfolder/

# Don’t change this line.
#不要修改下面2行

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change ’subfolder’ to be the folder you will use for your main domain.
#把下面的’subfolder’修改为你在主机上的子目录

RewriteRule ^(.*)$ /subfolder/$1

# Change yourdomain.com to be your main domain again.
# Change ’subfolder’ to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
#把下面的yourdomain.com 修改为你自己的主域名
#把下面的’subfolder’修改为你在主机上的子目录
#把紧跟在/后面的index.php 换成你站点的主文件,如index.php, index.html等等。

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: