在codeIgniter本地主机与生产服务器上的子域 [英] subdomains on localhost vs. production server under CodeIgniter

查看:149
本文介绍了在codeIgniter本地主机与生产服务器上的子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置什么本质上是型材上开发站点的子域。在'个人资料'会是用户创建的,即可以在任何时候发生。

I'm trying to set up what are essentially profiles on subdomains on a development site. The 'profiles' would be user-created, i.e. can happen at any time.

在本地,我知道我不能使用通配符主机条目或任何东西(在一个MAMP环境中运行,OS 10.6),我不知道如何去动态创建的条目。网站上的虚拟主机上运行。

Locally, I know I can't use wildcard host entries or anything (running in a MAMP environment, OS 10.6), and I'm not sure how to go about dynamically creating entries. The site runs on a vhost.

课程的下一个障碍是生产服务器,这是一个媒体寺GS(共享)服务器。再次,不知道如何去自动创建这些(在生产服务器的情况下)的DNS条目。

The next hurdle of course is the production server, which is a Media Temple gs (shared) server. Once again, no idea how to go about creating these (in the case of the production server) DNS entries automatically.

任何帮助/咨询非常多AP preciated!

Any assistance/advice is very much appreciated!

推荐答案

你所要寻找的可能是以下内容:

What you're looking for might be the following:

DNS:

创建一个包罗万象,在你的DNS的A项(* .example.com的)。

Create a "catch-all" A-entry in your DNS (*.example.com).

Apache的配置:

以下内容添加到您的.htaccess文件:

Add the following to your .htaccess file:

RewriteEngine On

# Extract the username from the subdomain
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
RewriteRule ^$ /profile.php?username=%1 [L]

PHP:

在您profile.php你突然在其$ _GET [用户名]变量名。

In your profile.php you suddenly have the username in the $_GET['username'] variable.

这篇关于在codeIgniter本地主机与生产服务器上的子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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