我无法让Facebook喜欢接受我的网站网址。使用Facebook开发的工具“URL Linter”,我发现Facebook出现以下错误:“网站无法访问无法访问http://www.domainname.com/categories/blouses.html页面。”
我正在运行一个网站,该网站使用了许多由PHP脚本“即时”创建的重写规则。当请求.html文档时,我使用htaccess将请求解析为PHP文件。
RewriteRule ^(.*).html$ url_controller.php [L]
url-controller.php包含以下代码:
require_once $_SERVER['DOCUMENT_ROOT'].'/lib/config.php';
list($url, $ext) = explode('.html', substr(mysql_real_escape_string($_SERVER['REQUEST_URI']), 1));
list($parent, $child) = explode('/', $url);
$get_product = mysql_query("SELECT p.id FROM product_languages AS pl INNER JOIN products AS p ON pl.product_id = p.id INNER JOIN shop_products AS sp ON sp.product_id = p.id && sp.shop_id = ".$GLOBALS['site_id']." WHERE pl.url_key = '{$url}' && pl.locale = '{$_SESSION['language']}' LIMIT 0,1") or die(mysql_error());
if(mysql_num_rows($get_product)) {
require_once './pages/view_product.php';
exit;
}
$get_parent = mysql_query("SELECT c.id FROM categories AS c INNER JOIN shop_categories AS sc ON sc.category_id = c.id && sc.shop_id = ".$GLOBALS['site_id']." INNER JOIN category_languages AS cl ON cl.category_id = c.id && cl.url_key = '{$parent}' && cl.locale = '{$_SESSION['language']}' WHERE parent = 1 && active = 1 LIMIT 0,1");
$get_child = mysql_query("SELECT c.id FROM categories AS c INNER JOIN shop_categories AS sc ON sc.category_id = c.id && sc.shop_id = ".$GLOBALS['site_id']." INNER JOIN category_languages AS cl ON cl.category_id = c.id && cl.url_key = '{$child}' && cl.locale = '{$_SESSION['language']}' WHERE parent = 0 && active = 1 LIMIT 0,1");
if(mysql_num_rows($get_parent) && mysql_num_rows($get_child)) {
require_once './pages/view_catalog.php';
exit;
}
$get_cms_page= mysql_query("SELECT p.id FROM cms_pages AS p INNER JOIN shop_cms_pages AS s ON p.id = s.page_id INNER JOIN cms_page_languages AS l ON p.id = l.page_id WHERE s.shop_id = '{$GLOBALS['site_id']}' AND l.url_key = '{$url}' AND p.active = 1 AND l.locale = '{$_SESSION['language']}' LIMIT 0,1") or die(mysql_error());
if(mysql_num_rows($get_cms_page)) {
require_once './pages/cms_page.php';
exit;
}
$get_rule = mysql_query("SELECT new_url, status FROM url_rewrite WHERE shop_id = ".$GLOBALS['site_id']." && old_url = '".str_replace('Webshop/','',$url)."' && locale = '{$_SESSION['language']}' LIMIT 0,1") or die(mysql_error());
$fetch_rule = mysql_fetch_array($get_rule);
if(mysql_num_rows($get_rule)) {
if($fetch_rule['status'] == 301) {
header ("HTTP/1.1 301 Moved Permanently");
//fix redirect to /
if($fetch_rule['new_url'] == '/') {
header ("Location: ".$fetch_rule['new_url']);
} else {
header ("Location: /".$fetch_rule['new_url'].".html");
}
exit;
}
elseif($fetch_rule['status'] == 302) {
header ("Location: /".$fetch_rule['new_url'].".html");
exit;
}
}
//IF WE GET TO THIS POINT; IT'S NOT BEEN POSSIBLE TO FIND THE REQUESTED URL ANYWHERE IN THE CATALOG
header("HTTP/1.0 404 Not Found");
require_once './pages/error_404.php';
exit;
我很难看到自己做错了什么 - 更糟糕的是,我开始考虑谷歌是否也可能无法访问我的网站?
我希望有人能用他们的经验和知识帮助我:)
提前致谢
答案 0 :(得分:0)
如果您转到Google Webmaster Tools,则可以将您的网页设为GoogleBot。这会告诉你谷歌是否有问题。你的代码似乎很好,但我没有花太多时间仔细查看它。