在bluehost上购买了空间,如何让一个主域名访问子目录呢,最简单方法是用 .htaccess 来进行限制。9 C8 `1 v/ q: i n. @ m
) \( R2 [5 L8 r! _% w% `4 I0 W
在bluehost 的/public_html 新建立一个 .htaccess 文件,如果没有这个文件的话。
' E% k/ B6 M0 X8 J- A/ F& u; { }7 z4 y" {$ F+ d; F% @3 I
拷贝下面代码放到 .htaccess 文件里
3 E2 W! v; x5 a+ T# u
+ h) v0 m% x( x6 G! G C! [# Bluehost.com
1 }" S" w& E+ e8 H( J) l/ {2 s# .htaccess main domain to subdirectory redirect: z) }" _. \. {5 e( D
# Copy and paste the following code into the .htaccess file
4 [( \" b) M7 n& w( x# in the public_html folder of your hosting account
2 e2 R3 g/ F5 ^# make the changes to the file according to the instructions.
% ]' e7 j0 D5 F& P7 S# Do not change this line.
. B/ H. q; v6 S. i pRewriteEngine on
; j, i( [- ]! ?4 S5 Y# Change yourdomain.com to be your main domain. 添加你的主域名% C* V u) B1 I) N# _
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$% v: k5 F5 e) n- ^# j
# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录
8 A9 D9 @3 ]' s9 y, j- `RewriteCond %{REQUEST_URI} !^/subdirectory/
' E7 x$ c/ @+ D4 w: y8 Q# Don't change this line.
2 F' Y6 { k- r. M2 k8 e' kRewriteCond %{REQUEST_FILENAME} !-f
$ N! s5 z) T: A5 j- h3 [% J, gRewriteCond %{REQUEST_FILENAME} !-d, Z, m) ~3 k2 A
# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录
# i' J1 F( f# t, L: d# a: l9 X QRewriteRule ^(.*)$ /subdirectory/$1
$ e; R) r1 d- V# G# p2 L# Change yourdomain.com to be your main domain again.
- k" C0 Y- m& Y! F6 G# Change 'subdirectory' to be the directory you will use for your main domain
# n' L( ]' } L/ l' @# followed by / then the main file for your site, index.php, index.html, etc. 主域名
+ {6 w1 L8 r7 w, jRewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$) B4 ?- C; U; o
RewriteRule ^(/)?$ subdirectory/index.php [L]: F+ ^5 E8 Z7 S" S; {
. I# [, t, X5 J ]
, Z: e& w6 ]7 @& {9 \* b) A6 r本文选自:Hello,Drupal,谢谢!2 F6 c; h4 A5 z% D' H
8 h3 C2 ~( c- i; h! ?
% }* ?- m l; A* l! P |
|