我有一个问题,我没有得到解决。我想使子域这样的 user1.domain.com,user2.domain.com等不断。用户1,用户2,用户...是 用户在我的网站。如何写htaccess的查询? 任何想法?
I have a problem that I do not get solved. I want to make subdomains such user1.domain.com, user2.domain.com and so continuously. user1, user2, user ... are users on my site. How to write a query in htaccess? any idea?
您需要先激活每个用户的目录:看的 http://httpd.apache.org/docs/trunk/en/howto/public_html.html
You need to activate the per-user directories first : see http://httpd.apache.org/docs/trunk/en/howto/public_html.html
然后你可以在你的mod_rewrite
别名 user1.domain.com
到站点。 COM /〜用户1
,如:
Then you can you mod_rewrite
to alias user1.domain.com
to domain.com/~user1
, like:
RewriteEngine on
RewriteCond %{HTTP_HOST} (.*).domain.com
RewriteRule (.*) http://domain.com/~%1/$1
要简单。您也可以按用户重写规则进行,如果你不希望使用一个全局设置,你没有太多的用户。
To be simple. You can also make per user RewriteRule if you don't want to use a global setting and you don't have too many users.