Apache的htaccess的子域名重定向错误 [英] Apache htaccess subdomain redirect error

查看:82
本文介绍了Apache的htaccess的子域名重定向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我没有得到解决。我想使子域这样的 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.

这篇关于Apache的htaccess的子域名重定向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆