Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 多域编码_Php_Codeigniter - Fatal编程技术网

Php 多域编码

Php 多域编码,php,codeigniter,Php,Codeigniter,嗨,我们有一个关于codeigniter PHP的项目,在我的控制器中有两个文件夹 成员 管理员 我可以像这样访问这些文件夹 http://example.com/member http://example.com/admin 但我不希望任何人访问像上面的域这些文件夹,如果任何一个访问像上面的域显示404错误页面 我希望任何人访问这些文件夹,以帮助子域 像 我的问题是如何为codeigniter文件夹中的不同文件夹创建子域 如何显示上述问题的错误404页面实现这一点的一种方法是使用@Sag

嗨,我们有一个关于codeigniter PHP的项目,在我的控制器中有两个文件夹

  • 成员
  • 管理员
我可以像这样访问这些文件夹

http://example.com/member
http://example.com/admin
但我不希望任何人访问像上面的域这些文件夹,如果任何一个访问像上面的域显示404错误页面

我希望任何人访问这些文件夹,以帮助子域 像

我的问题是如何为codeigniter文件夹中的不同文件夹创建子域
如何显示上述问题的错误404页面

实现这一点的一种方法是使用@Sagar Khatri提到的通配符子域或特定子域和HTACCESS

创建子域:member.site.com&admin@site.com

现在使用HTACCESS文件(这是一个Apache配置文件),我们将限制对这些子域的访问

# dont allow acces to the admin controller not under the admin subdomain
RewriteCond %{HTTP_HOST} !^admin.site.com$ [NC]
RewriteCond $1 ^index.php/admin/(.*) [NC]
RewriteRule (.*) http://%{HTTP_HOST}/your-404-page
成员控制器也是如此

#dont allow acces to the member controller not under the member subdomain
RewriteCond %{HTTP_HOST} !^member.site.com$ [NC]
RewriteCond $1 ^index.php/member/(.*) [NC]
RewriteRule (.*) http://%{HTTP_HOST}/your-404-page
记住,一旦你有了子域,如果你不限制它,进入admin.site.com下站点的用户将能够看到该站点的所有其他页面(除了members controller),如果你只想限制他们对admin controller的访问,你必须添加另一个重写规则。

只需这样做

$config['base_url'] = '';

在config.php中为您的应用程序启动

我认为您应该使用通配符子域功能。请检查此项。大多数问题都已回答,请在搜索字段中或甚至在此处查询一些问题。:)感谢这是对受限于域的唯一回复。请告诉我如何为CodeIgniter创建子域。您必须首先在服务器中创建子域,以便您的web服务器知道将请求转发到这些子域的位置,然后在CodIgniter中,您需要设置base_url变量。
$config['base_url'] = '';