简体   繁体   English

PHP只重定向根域

[英]PHP redirect only root domain

i need a php code redirect only my index page to another site very fast somthing like this but the problem is : this code redirect all page 我需要一个PHP代码只将我的索引页重定向到另一个站点非常快这样的东西,但问题是:此代码重定向所有页面

 <?php    
  header('Status: 301 Moved Permanently', false, 301);      
  header( 'Location: http://www.fastfreesurfing.cf/' ) ;      
  exit();      
?>

Do this: 做这个:

if ($_SERVER['REQUEST_URI'] == '/' || strtolower($_SERVER['REQUEST_URI']) == '/index.php') {
    header('Status: 301 Moved Permanently', false, 301);      
    header( 'Location: http://www.fastfreesurfing.cf/' ) ;      
    exit();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM