通过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>
标签:RewriteRule,abc,xyz,REQUEST,htaccess,文件夹,根目录,RewriteCond,com 来源: https://www.cnblogs.com/qingsong/p/10353085.html