HostMonster主机重写主域名

百科 @ April 21, 2009 3:04 pm | No Comments | Comments Feed | Trackback

Tags:


在虚拟主机中,主域名是使用public_html目录/文件夹作为主域名的缺省目录,主域名网站的文件和程序都是放在public_html目录下,附加的域名(addon domains)使用public_html目录/文件夹下的子目录/子文件夹。有的人可能觉得public_html目录/文件夹下的会看起来比较乱,因此想把主域名也指向其中一个子目录/文件夹。这样就需要利用.htaccess的重写功能。

具体的写法如下:

# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line.

RewriteEngine on

# Change yourdomain.com to be your main domain.

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

# Change ’subfolder’ to be the folder you will use for your main domain.

RewriteCond %{REQUEST_URI} !^/subfolder/

# Don’t change this line.

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

# Change ’subfolder’ to be the folder you will use for your main domain.

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.

RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
RewriteRule ^(/)?$ subfolder/index.php [L]

相关文章:

  1. SEO优化之301页面重定向
  2. 更改Lunarpages主FTP帐号密码
  3. 如何登陆Lunarpages主机的LPCP面板?
  4. 重新订购Lunarpages的Windows Hosting
  5. BlueHost开通SSH的信件

Font: Large   Normal   Small

Leave a comment

Log in to leave a comment or comment anonymously.


Name (required)

E-mail (required)

Website

Spam Protection by WP-SpamFree

RSS WordPress资讯
  • 自定义默认头像
    WordPress带有默认头像,如果你不喜欢,想用一个自己自定义的默认头像,很简单,自己创建一个然后使用代码更换就OK,把这段代码放在functions.php中。 […]
  • Google继续主宰美国搜索市场
    根据ComScore公布的数据,Google在一月份,继续以66.2%的市场份额统治美国的搜索引擎市场。 相对比说第三名雅虎上个月的日子不是那么好过,市场占有下降了0.4%,市场份额为14.1%。在过去的一年,雅虎的市场份额一直在稳步下降,在十二月,终于被微软的Bing超过,推倒第三位。一年前雅虎的搜索市场份额为16%。 现在微软有15.2的市场份额,一月份增长0.1% 去年十二月份,美国整体查询上升了2%,然而在一月份,下降了两个百分点。 […]