如何在[htaccess]网站上为我的所有用户显示子域中所有子目录的内容?

时间:2019-06-14 11:52:59

标签: php apache .htaccess

我将显示使用htaccess生成的子域中子目录的内容。 实际上,我必须为在我的网站上注册的所有用户创建一个子域

我的网站示例example.com:

/index.php
      user1/
      user2/
      user3/

显然,URL现在是:

example.com/user1/
example.com/user2
etc...

但是只要文件user1.example.com

,我都会在浏览器user2.example.com.htaccess等中显示……而无需更改

谢谢大家!

1 个答案:

答案 0 :(得分:0)

在.htaccess文件顶部检查此重写

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com
RewriteRule ^(.*)$ http://example.com/%1/$1 [L]