這是一個奇怪的位,我有一個PHP文件,有時會給出404錯誤。這是我製作的wordpress插件的ajax回調頁面。爲什麼一個已知的PHP文件給404?
例如:
顯然,PHP文件是存在的還是第一個鏈接是行不通的,所以爲什麼不第二個鏈接工作?
有趣的是,使用完全相同的代碼我的服務器上的麻煩鏈接做工精細:http://petewilliams.info/blog2/wp-content/plugins/amazon-affiliate-link-localizer/ajax.php?strAction=search&strLink=http://www.amazon.com/dp/B000IZGIA8
可悲的是我沒有說是有問題的服務器直接訪問,但是我可以要求改變被製造。這不僅僅是這個網站有問題,腳本的其他用戶也有同樣的問題。
下面是該文件的源代碼,沒有太多吧:
<?php
header("Content-type: application/javascript");
switch ($_REQUEST['strAction']) {
case 'search':
searchLink();
break;
case 'version':
echo "1.7b";
break;
default:
checkLinks();
break;
}
function checkLinks() {
// get URL
$strTld = $_REQUEST['strTld'];
$strAffiliateId = $_REQUEST['strAffiliateId'];
$strLinks = $_REQUEST['strLinks'];
$arrLinks = explode('|', $strLinks);
foreach ($arrLinks as $strAsin) {
$strLink = "http://www.amazon.$strTld/exec/obidos/ASIN/$strAsin/$strAffiliateId";
$arrHeaders = get_headers($strLink, 1);
// if not found, then search for it
if (strpos($arrHeaders[0], '404') || strpos($arrHeaders[1], '404')) {
echo "arrLinksToCheck[ '$strAsin' ].searchLink();\n";
} else {
echo "arrLinksToCheck[ '$strAsin' ].localiseLink();\n";
}
}
}
function searchLink() {
$strHtml = file_get_contents($_REQUEST['strLink'], false, null, -1, 100000);
$strPattern = '/canonical" href="http:\/\/(.*)\/(.*)\/dp\/([A-Z0-9]{10})/';
preg_match($strPattern, $strHtml, $arrMatches);
$strTitle = str_replace( '-', '%20', $arrMatches[2]);
// the canonical ASIN is sometimes different to the original one which confuses the JS, so use the one in the original link
$strPattern2 = '/\/([A-Z0-9]{10})/';
preg_match($strPattern2 , $_REQUEST['strLink'], $arrUrlMatches);
$strAsin = is_array($arrUrlMatches) ? $arrUrlMatches[1] : $arrMatches[3];
echo "arrLinksToCheck[ '{$strAsin}' ].writeSearchLink('$strTitle');\n";
}
任何人有任何想法,這是怎麼回事?
感謝
皮特