简体   繁体   中英

How to show content of all sub-directory in sub-domain for all my user on the site [htaccess]?

I would show the content of sub-directory in a sub-domain generate with htaccess. Practically I must create a sub-domain for all user that register on my website

Example of my site web example.com:

/index.php
      user1/
      user2/
      user3/

Obviously the url are now:

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

But I would show in the browser user1.example.com , user2.example.com , etc... without change whenever the file .htaccess

Thank you all!

Check this rewrite in top of your .htaccess file

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM