[英]CodeIgniter: Redirect URL with subdomain
I am trying to redirect a subdomain URL to a controller method. 我正在尝试将子域URL重定向到控制器方法。 Complete url is
完整的网址是
http://subdomain.domain.com/urlofservice/servicename.svc
Part1 I have configured subdomain from hosting service's control panel. 第1部分我已经从托管服务的控制面板配置了子域。 Which is redirecting
subdomain.domain.com
to domain.com
这是将
subdomain.domain.com
重定向到domain.com
Part2 第2部分
Configured route url on router.php as 在router.php上配置路由URL为
$route['urlofservice/servicename.svc'] = "test/test3";
But when I try to hit the complete url, I get 404 error from the hosting service. 但是,当我尝试点击完整的网址时,我从托管服务收到404错误。 404 error is thrown from hosting server not from codeigniter.
从托管服务器而不是从codeigniter抛出404错误。
Is there any problem with my seetting? 我的seetting有问题吗?
Should I change redirection setting in .htaccess or in server control panel? 我应该更改.htaccess或服务器控制面板中的重定向设置吗? Right now server is throwing 404 error which means it's not even hitting the application yet.
现在服务器正在抛出404错误,这意味着它甚至还没有打到应用程序。
You can't use routes directly for subdomain. 您不能直接将路由用于子域。 Use this in your
routes.php
在
routes.php
使用它
if (strstr($_SERVER['HTTP_HOST'], 'subdomain.domain.com')) {
$route['urlofservice/servicename.svc'] = "test/test3";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.