PHP - 通过子域的动态页面
我正在使用通配符 DNS 设置基于子域创建个人资料页面。
问题是,如果子域不正确,我希望它重定向到同一页面,但前面没有子域,即;
if ( preg_match('/^(www\.)?([^.]+)\.domainname\.co.uk$/', $_SERVER['HTTP_HOST'], $match)) {
$DISPLAY_NAME = $match[2];
$query = "SELECT * FROM `" . ACCOUNT_TABLE . "` WHERE DISPLAY_NAME = '$DISPLAY_NAME' AND ACCOUNT_TYPE = 'premium_account'";
$q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() );
if( mysql_num_rows( $q ) != 0 ) {
}else{
mysql_close( $CON );
header("location: http://www.domainname.co.uk");
exit;
}
我
收到浏览器错误: Firefox 检测到服务器正在以一种永远不会完成的方式重定向对此地址的请求。
我认为这是因为在使用 header("location: http ://www.domainname.co.uk");
它仍然将子域放在前面,即; header("location: http://www.sub.domainname.co.uk");
有谁知道如何对此进行排序和/或问题是什么。
问候,
菲尔
im creating profile pages based on a subdomains using the wildcard DNS setting.
Problem being, if the subdomain is incorrect, I want it to redirect to the same page but without the subdomain infront ie;
if ( preg_match('/^(www\.)?([^.]+)\.domainname\.co.uk$/', $_SERVER['HTTP_HOST'], $match)) {
$DISPLAY_NAME = $match[2];
$query = "SELECT * FROM `" . ACCOUNT_TABLE . "` WHERE DISPLAY_NAME = '$DISPLAY_NAME' AND ACCOUNT_TYPE = 'premium_account'";
$q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() );
if( mysql_num_rows( $q ) != 0 ) {
}else{
mysql_close( $CON );
header("location: http://www.domainname.co.uk");
exit;
}
}
I get a browser error: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
I think its because when using header("location: http://www.domainname.co.uk");
it still puts the sub domain infront i.e. ; header("location: http://www.sub.domainname.co.uk");
Does anyone know how to sort this and/or what is the problem.
Regards,
Phil
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当网页无限循环地重定向您时,就会发生这种情况。因此,您所引用的页面可能也引发了推荐(或者 Firefox 认为是)。
Mozilla 知识库说明了您可以对此错误采取哪些措施。
This happens when a webpage redirects you in an endless loop. So probably the page you are referring too is also sparking a referral (or firefox thinks it is).
Mozilla knowledge base explains what you can do about this error.
想通了这一点。这是由于浏览器缓存造成的。
成功了。
Figured this one out. It was due to the browser caching.
did the trick.