通过htaccess文件配置多个一级域名指向根目录的子文件夹

  创建.htaccess文件,在Windows系统创建时要写成“.htaccess.”,不带双引号,否则不会创建成功。

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
 
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
 
    #绑定 localhost 到 public子目录
    RewriteCond %{HTTP_HOST} ^localhost$ [NC]
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1?Rewrite [L,QSA]
 
    #绑定 www.abc.com 到 abc子目录
    RewriteCond %{HTTP_HOST} ^www.abc.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/abc/
    RewriteRule ^(.*)$ abc/$1?Rewrite [L,QSA]
 
    #绑定 hello.com 到 hello子目录
    RewriteCond %{HTTP_HOST} ^hello.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/hello/
    RewriteRule ^(.*)$ hello/$1?Rewrite [L,QSA]
 
    #绑定 www.xyz.com 到 xyz子目录
    RewriteCond %{HTTP_HOST} ^www.xyz.com$ [NC]
    RewriteCond %{REQUEST_URI} !^/xyz/
    RewriteRule ^(.*)$ xyz/$1?Rewrite [L,QSA]
</IfModule>

 

上一篇:OJ(整除)


下一篇:浏览器的同源策略及跨域解决方案