虚拟主机不支持子目录的情况下借助.htaccess实现多个域名重定向到子目录实现单空间多站点

举例:
有多个域名:site1.haoduck.comsite2.haoduck.comsite3.haoduck.com
分别在二级目录site1.haoduck.com/site2.haoduck.com/site3.haoduck.com/

.htaccess的代码如下

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} ^site1.haoduck.com$
  3. RewriteCond %{REQUEST_URI} !^/site1.haoduck.com/
  4. RewriteCond %{REQUEST_FILENAME} !-f
  5. RewriteCond %{REQUEST_FILENAME} !-d
  6. RewriteRule ^(.*)$ /site1.haoduck.com/$1
  7. RewriteCond %{HTTP_HOST} ^site1.haoduck.com$
  8. RewriteRule ^(/)?$ site1.haoduck.com/index.php [L]
  9.  
  10. RewriteCond %{HTTP_HOST} ^site2.haoduck.com$
  11. RewriteCond %{REQUEST_URI} !^/site2.haoduck.com/
  12. RewriteCond %{REQUEST_FILENAME} !-f
  13. RewriteCond %{REQUEST_FILENAME} !-d
  14. RewriteRule ^(.*)$ /site2.haoduck.com/$1
  15. RewriteCond %{HTTP_HOST} ^site2.haoduck.com$
  16. RewriteRule ^(/)?$ site2.haoduck.com/index.php [L]
  17.  
  18. RewriteCond %{HTTP_HOST} ^site3.haoduck.com$
  19. RewriteCond %{REQUEST_URI} !^/site3.haoduck.com/
  20. RewriteCond %{REQUEST_FILENAME} !-f
  21. RewriteCond %{REQUEST_FILENAME} !-d
  22. RewriteRule ^(.*)$ /site3.haoduck.com/$1
  23. RewriteCond %{HTTP_HOST} ^site3.haoduck.com$
  24. RewriteRule ^(/)?$ site3.haoduck.com/index.php [L]
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇