在bluehost上购买了空间,如何让一个主域名访问子目录呢,最简单方法是用 .htaccess 来进行限制。, G* A/ h; S" x6 n. q
t) v" h8 V4 u' w在bluehost 的/public_html 新建立一个 .htaccess 文件,如果没有这个文件的话。/ @' s& v9 x8 j3 T6 K3 M: {
( g- E* [7 w. f8 _% ~0 b
拷贝下面代码放到 .htaccess 文件里
* t5 }2 u. h y8 L5 t- s, W. D7 O
# Bluehost.com
. X6 c& M7 X. X# .htaccess main domain to subdirectory redirect8 e. E: i3 g3 v$ s( p* u
# Copy and paste the following code into the .htaccess file# `# X e& i$ K1 L1 e. Z
# in the public_html folder of your hosting account
5 J _0 C3 H8 W) H% D& M4 y8 k# make the changes to the file according to the instructions.
% |0 R- j5 i& ~# Do not change this line.
' j: U/ U3 a* H8 F- X& |RewriteEngine on
) R7 H% `8 C8 A/ C1 I% t+ @$ W) D# Change yourdomain.com to be your main domain. 添加你的主域名 ]' _" F; D) Z
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
+ s7 z7 @' {7 R4 q4 u8 _) ~# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录' u5 i2 a: _0 P4 Y' V" b
RewriteCond %{REQUEST_URI} !^/subdirectory/: P, P3 S* ?5 E' v0 L/ F* ]
# Don't change this line." r% e, B; |! ^9 a9 Y/ T; C# ]2 y" U. P
RewriteCond %{REQUEST_FILENAME} !-f( ]: l) @9 \* k6 ]4 j4 F
RewriteCond %{REQUEST_FILENAME} !-d
$ e9 c0 G1 h: }: G7 \) C# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录: _: ?: V+ ]* t8 O7 k1 b& v. G
RewriteRule ^(.*)$ /subdirectory/$1+ E& U m i1 O, X8 Q5 M3 U1 D
# Change yourdomain.com to be your main domain again.2 z2 n8 k6 r. \
# Change 'subdirectory' to be the directory you will use for your main domain
+ F7 m5 }5 f9 F# followed by / then the main file for your site, index.php, index.html, etc. 主域名% v! \, z+ K: v- c/ q% t
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
( E4 e) P. T2 SRewriteRule ^(/)?$ subdirectory/index.php [L]
# o2 u, X. B: t% R4 u2 C* q6 Z, ?. u1 `# ~- C# W! m
$ \0 Q3 _4 ]! D a1 m本文选自:Hello,Drupal,谢谢!0 H/ M1 }8 G% @# [; J
3 ^# b; m! c2 u/ j3 S0 R1 U! q) A; a4 B8 e4 Q$ G
|
|