国外设计欣赏网站 - DOOOOR.com

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,微信登陆

搜索

[Drupal教程] Drupal 6.X:主域名映射到子目录文件夹的方法 .htaccess (Bluehost)

[复制链接]
发表于 4-13-2012 23:09 | 显示全部楼层 |阅读模式
在bluehost上购买了空间,如何让一个主域名访问子目录呢,最简单方法是用 .htaccess 来进行限制。
2 I+ N% B/ `$ {
5 i! R2 o5 p* s/ B3 B+ V" t在bluehost 的/public_html 新建立一个 .htaccess 文件,如果没有这个文件的话。
2 I) s( {! N0 P" S: Q, p0 b) h6 R4 m
. M" ?2 e) @- \8 a3 a" S拷贝下面代码放到 .htaccess 文件里( t( w8 y* J1 L$ F8 s

/ a0 b# y' f: B; i$ }; Q# Bluehost.com# l& ]. h8 p, p9 [, I: H( j1 b2 ]
# .htaccess main domain to subdirectory redirect
9 T8 ^2 a2 a" W, q0 b# Copy and paste the following code into the .htaccess file
2 i4 B; M( R* v# in the public_html folder of your hosting account" h$ _8 @6 [% x3 Q8 z
# make the changes to the file according to the instructions.
  G4 g/ |  g1 S3 J7 I+ y& w# Do not change this line.
) k5 ?, J6 w/ LRewriteEngine on
% |2 }# r4 u: Q$ g4 W* G! ]# Change yourdomain.com to be your main domain. 添加你的主域名
3 [3 ^  X9 Y1 `0 n5 DRewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$/ H, p' b# x: o. E
# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录# ^) U, ~' E; v& D
RewriteCond %{REQUEST_URI} !^/subdirectory/
( y/ M3 _: t: F* p, b# Don't change this line.
/ a5 k: Q8 P4 d" K' H. ]RewriteCond %{REQUEST_FILENAME} !-f0 d( m/ ?- Z/ f
RewriteCond %{REQUEST_FILENAME} !-d4 u. a' R7 C) E6 A' T- S6 J
# Change 'subdirectory' to be the directory you will use for your main domain. 需要指定的子目录; E. t# W/ c% O; P: t, Z9 C
RewriteRule ^(.*)$ /subdirectory/$1
5 V1 Z  T0 E& r. i; ]" w# Change yourdomain.com to be your main domain again.. S) U1 ^9 a: |) U0 ^
# Change 'subdirectory' to be the directory you will use for your main domain9 k& U( C) \/ {, e1 F6 }! ]# Y
# followed by / then the main file for your site, index.php, index.html, etc. 主域名; f" Z  O# u) R, z
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$2 G$ f3 [$ G/ [0 C
RewriteRule ^(/)?$ subdirectory/index.php [L]
: [0 R7 R! z2 X1 S7 j
1 o2 B# [3 j4 y* ~4 J! b8 [" Q% U+ X$ K: S% V
本文选自:Hello,Drupal,谢谢!
  v2 a2 Z; k+ _* ^. S' g% j* ]& ~( M* ]; s4 o! }' }5 Q. j- H

5 ]- B/ W1 X$ T) d/ ?, o3 a

|2011-2026-版权声明|平台(网站)公约|DOOOOR 设计网 ( 吉ICP备2022003869号 )

GMT+8, 5-1-2025 05:09 , Processed in 0.510262 second(s), 154 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表