创建.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>

 

相关文章:

  • 2021-06-23
  • 2022-12-23
  • 2021-10-23
  • 2023-01-03
  • 2021-07-08
  • 2022-12-23
  • 2021-12-13
  • 2021-05-26
猜你喜欢
  • 2022-02-07
  • 2022-12-23
  • 2021-12-16
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案