想要在codeigniter中创建动态子域吗? [英] Want to create dynamic subdomain in codeigniter?

查看:114
本文介绍了想要在codeigniter中创建动态子域吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站中,我想为用户添加一个功能,以使用他们的域名用户名。

In my site i want to add an functionality for user to use their username with domain.

像codeigniter现在我想给用户使用他们

Like in codeigniter right now i want to give the user to use their own url to login in site and do other stuff.

例如:

我想要 www.username.mysite.com/login www.username.mysite.com/category

所以这里用户可以用他们的凭证登录并添加类别。所以我有两个控制器在我的网站与登录和类别。

so here the user can login with their credential and add the category. so i have two controller in my site with login and category.

所以如何做这个路由或.htaccess。

So how to do this with the routes Or .htaccess.

推荐答案

这里是您的问题的解释。 http://www.joehayes.org/setting-up-wildcard -dns-for-subdomains.html

here's an explanation of your issue here. http://www.joehayes.org/setting-up-wildcard-dns-for-subdomains.html

如果您已阅读该链接上的说明,则可以知道您应重定向所有子域到www第一。在httpd.conf文件中有一个虚拟主机定义,只包含 yourdomain.com ,以将所有请求重定向到您的DocumentRoot。

Ok if you have read the explanation on the link, you'd know that you should redirect all of your subdomains to www first. in httpd.conf file there's a virtual host definition containing only yourdomain.com to redirect all the requests to your DocumentRoot.

**ServerAlias yourdomain.com**
ServerAdmin webmaster@yourdomain.com
DocumentRoot /home/yourdoma/public_html
BytesLog domlogs/yourdomain.com-bytes_log
ServerName www.yourdomain.com
User yourdomain
Group yourdomain
CustomLog /usr/local/apache/domlogs/yourdomain.com combined
ScriptAlias /cgi-bin/ /home/yourdomain/public_html/cgi-bin/

,您应该将 ServerAlias 修改为 *。yourdomain.com ,即可将所有子域都恢复到文档根目录文件夹中。那么您应该能够 mod_rewrite 网址解析您的uri成功。

and you should modify the ServerAlias to *.yourdomain.com to retrieve all subdomains into your Document Root folder. then you should be able to mod_rewrite or url parse your uri to succeed this.

这篇关于想要在codeigniter中创建动态子域吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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