Skip to content

Instantly share code, notes, and snippets.

@allex
Last active October 12, 2015 22:27
Show Gist options
  • Save allex/4095938 to your computer and use it in GitHub Desktop.
Save allex/4095938 to your computer and use it in GitHub Desktop.
.htaccess重写让空间绑定多个域名到不同的目录支持多站点
# see also http://www.freehao123.com/htaccess-godaddy/
# root .htaccess
<IfModule mod_rewrite.c>
# 关闭目录列表
Options -Indexes
RewriteEngine on
# 预设页面
DirectoryIndex default.html index.html default.html index.htm default.php index.php
# 统一网址,去掉www。如果你想保留www,自己在第二行添加
RewriteCond %{HTTP_HOST} ^0baidu.tk[NC]
RewriteRule ^(.*)$ http://0baidu.tk/$1 [L,R=301]
# 将域名绑定在特定的目录当中。0baiud.tk是我建立的文件目录
RewriteCond %{HTTP_HOST} ^(www.)?0baidu.tk$ [NC]
RewriteRule ^(.*)$ /0baidu.tk/$1 [L]
</IfModule>
# subdirectory
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /0baidu.tk/
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment