首页 > SEO及其它点滴 > 如何让主域名指向public_html下的子目录 – PHP国外空间。

如何让主域名指向public_html下的子目录 – PHP国外空间。

编辑public_html目录下的.htaccess文件,加入如下语句.如果public_html下没有.htaccess文件,新建一个即可.
注意:将 yourmaindomain.com修改为你的域名,将subfolder修改为你要指向的public_html下的子目录.最后一行中的index.php修改为你的网站的主页名称.(修改粗体表示的内容,其他内容不要改动),最后一行“subfolder/”与“[L]”之间有一空格,请不要删除空格,否则将会出现找不到文件的错误。

# www.host114.org
# .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.

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/ [L]

  1. 2010年1月26日20:21 | #1

    高手啊!

  2. 2010年2月10日17:19 | #2

    博主的网站风格很好,有时间大家交流下。我的站是悠悠导购http://uuude.com

  3. 2010年2月19日16:10 | #3

    哈哈。。。我们也来了。。。
    一切都会好的。。。。。

  4. 2010年2月26日00:14 | #4

    来了~踩一脚~呵呵~给你空间增添人气哦~最近还好吧~

  5. 2010年3月21日19:40 | #5

    夜光粉(www.gyfgcl.com)
    向蓝天借一朵云彩写上“甜蜜”!

    向大地借一片绿叶写上“吉祥”!

    向银河借一颗星星写上“快乐”!

    向明月借一抹清辉写上“美梦成真”!

    愿我的祝福能够带给你幸福快乐!

  6. 2010年3月27日13:30 | #6

    文章写的很好,很有感情!文章写的很好,很有感情!文章写的很好,很有感情!文章写的很好,很有感情!文章写的很好,很有感情!

    we sell discount nike shoes,cheaper adidas shoes,mbt shoes on sale.welcome to our weisite!

  1. 本文目前尚无任何 trackbacks 和 pingbacks.