Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/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 - Fatal编程技术网

Php 基于子域删除重复项

Php 基于子域删除重复项,php,Php,一个小型php项目需要我删除基于子域的重复url,因为每个url方案都有一个或多个子域。我需要php大师给我一些关于如何做到这一点的指导。我不是在要求现成的代码,而是一些指导 http://en.example.com http://usa.en.example.com 我使用以下代码来解析子域。我想集成这个代码。多谢各位 $url = 'http://en.example.com'; $parsedUrl = parse_url($url); $host = explode('.', $

一个小型php项目需要我删除基于子域的重复url,因为每个url方案都有一个或多个子域。我需要php大师给我一些关于如何做到这一点的指导。我不是在要求现成的代码,而是一些指导

http://en.example.com
http://usa.en.example.com
我使用以下代码来解析子域。我想集成这个代码。多谢各位

$url = 'http://en.example.com';

$parsedUrl = parse_url($url);

$host = explode('.', $parsedUrl['host']);

$subdomain = $host[0];
echo $subdomain;
只想提取:

http://subdomain1.example.com/spo/4444713932
http://subdomain2.example.com/spo/4474641611
http://subdomain3.example.com/spo/4410408197
从这个列表中

 http://subdomain1.example.com/spo/4444713932
 http://subdomain1.example.com/spo/4415697470
 http://subdomain1.example.com/spo/4446009678
 http://subdomain2.example.com/spo/4474641611
 http://subdomain2.example.com/spo/4477100572
 http://subdomain3.example.com/spo/4388005447
 http://subdomain3.example.com/spo/4410408197

现在还不清楚你想在这里做什么。当你说“删除”子域时。您是在尝试从一个子域重定向到另一个子域,还是只是在讨论解析URL中主机名的子域信息?不,我正在尝试完全删除重复的URL。子域是唯一的。同样,通过“删除重复URL”,您是否希望能够将请求重定向到
en.example.com
usa.en.example.com
,或者反之亦然?如果是这样的话,您可能会希望在您选择的web服务器上探索URL重写(即Apache的mod_rewrite)。嗨,Mike,请参阅我最近的编辑以获得更多说明。我认为主要逻辑是使用一个数组,其中子域作为键,URL作为值。循环浏览列表并将所需子域和URL提取到数组中。