开发者

Apache htaccess subdomain redirect error

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?


You need to activate the per-user directories first : see http://httpd.apache.org/docs/trunk/en/howto/public_html.html

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.


You can use a combination of the wildcard option in apache's VirtualHost configuration section, and mod_rewrite. An article with some good details can be found here:

http://www.debian-administration.org/articles/358

This would have to be done in your apache configuration httpd.conf file, however, as .htaccess does not allow for VirtualHost sections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜