简体   繁体   English

基于URL的可变PHP重定向

[英]Variable php redirect based on url

i'm creating a index.php file for redirect all website to specific host I'd like create a little php script that read url and redirect based on specific filter. 我正在创建一个index.php文件,用于将所有网站重定向到特定主机,我想创建一个小的php脚本,以读取URL并根据特定过滤器进行重定向。

for example: if url = (everything).domain1.com redir to default1.php if url = (everything).domain2.com redir to default2.php in all other case that not like first or second redir to default3.php 例如:如果url =(everything).domain1.com重载到default1.php如果url =(everything).domain2.com重载到default2.php,在所有其他情况下都不喜欢将first或second重载到default3.php

this is possible with php? 这是可能的PHP? i must use $_SERVER['HTTP_HOST'] or can I use other method? 我必须使用$ _SERVER ['HTTP_HOST']还是可以使用其他方法?

i resolved with: 我解决了:

    <?php 
$domain = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
if (strpos($domain,'domain-name.com') == true) {
    header('location: /index2.php');
    exit();
} else {
    header('location: /index3.php');
}
?>

but not redirect... 但不能重定向...

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

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