raksmart活动促销

分享

写回答

发帖

找变论坛,没有解决的问题

回答|共 19 个

开心私塾

发表于 2010-7-1 17:19:55 | 显示全部楼层

没有试过,不过这个可以拿来参考一下呵呵。

szipcam

发表于 2010-7-3 13:35:26 | 显示全部楼层

回顾问题,顶一下

johnnyfu829

发表于 2010-7-3 20:52:23 | 显示全部楼层

下面这个应该就是你要的答案了:

Problem:
How do I make a sub directory (or sub folder) act as the public_html for your main domain?
Solution:
The main domain on the hosting account uses the public_html directory for all of its Web site files. Addon domains use sub directories inside the public_html directory. In order to also set up your main domain to use a subdirectory on your hosting account you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subdirectory on public_html.
To setup the rewrite/redirect, edit the ~/public_html/.htaccess file. Insert the following code block and make modifications as noted in the (#) comments.


# Bluehost.com
# .htaccess main domain to subdirectory 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 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1
# Change yourdomain.com to be your main domain again.
# Change 'subdirectory' to be the directory 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 ^(/)?$ subdirectory/index.php [L]

Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as http://www.yourdomain.com/page.html.

具体地址是:http://helpdesk.bluehost.com/index.php/kb/article/000347

johnnyfu829

发表于 2010-7-3 21:02:44 | 显示全部楼层

你要做的就是在public_html或者www这个目录下,创建一个.htaccess,那个“.”不要忘记了。如果你的主域名,也就是你说的bluehost送的那个免费域名,如果是abc.com,abc.com要绑定的文件夹是abc。那么.htaccess的内容如下,我把注释的都去掉:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?abc.com$
RewriteCond %{REQUEST_URI} !^/abc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /abc/$1
RewriteCond %{HTTP_HOST} ^(www.)?abc.com$
RewriteRule ^(/)?$ abc/index.php [L]

以上这个是带www的。就是你希望别人访问你的站点是www.abc.com

如果你想你的网址不带www,就是希望别人访问你的站点的时候是abc.com这样的形式,那么.htaccess的内容如下:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*\.)?abc.com$
RewriteCond %{REQUEST_URI} !^/abc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /abc/$1
RewriteCond %{HTTP_HOST} ^(.*\.)?abc.com$
RewriteRule ^(/)?$ abc/index.php [L]

szipcam

发表于 2010-7-4 13:42:09 | 显示全部楼层

这个办法好像没用呀

johnnyfu829

发表于 2010-7-4 18:09:32 | 显示全部楼层

难道你不是想把主域名绑到根目录下的子目录吗?

gypworks526

发表于 2010-7-4 21:16:02 | 显示全部楼层

回复 16# 的帖子

他的意思好像不是把主域名绑定到子目录。而是添加的域名不想主域名+目录的方式访问。
RAKSmart

johnnyfu829

发表于 2010-7-4 23:37:56 | 显示全部楼层

原帖由 gypworks526 于 2010-7-4 09:16 PM 发表
他的意思好像不是把主域名绑定到子目录。而是添加的域名不想主域名+目录的方式访问。


把主域名绑到子目录上,让主域名和其他域名都并列在根目录下不就可以了,我给他提供的方法不就是解决他这个问题的吗?我实在想不通他想要表达什么..............

/主域名/
/其他域名1/
/其他域名2/
.
.
.
/其他域名N/
这样不就是让你实现了不用主域名+目录的方式访问其他域名的站点了吗?

开心私塾

发表于 2010-7-5 08:40:38 | 显示全部楼层

麻烦楼上的重新看一下楼主的问题。你可能是误解了楼主的意思。

gypworks526

发表于 2010-7-5 08:56:25 | 显示全部楼层

原帖由 johnnyfu829 于 2010-7-4 11:37 PM 发表


把主域名绑到子目录上,让主域名和其他域名都并列在根目录下不就可以了,我给他提供的方法不就是解决他这个问题的吗?我实在想不通他想要表达什么..............

/主域名/
/其他域名1/
/其他域名2/
.
.
.
/其他域名N/
...




但是主域名+目录的方式 也同样是可以访问的. 楼主的意思我猜测是:不要这种方式访问.
您需要登录后才可以回帖 登录 | 注册

本版积分规则