I'm having trouble with getting Facebook Like to accept my website URL's. Using the the Facebook developed tool "URL Linter", I have found out that Facebook get's the following error: "Website Inaccessible The page at http://www.domainname.com/categories/blouses.html could not be reached."
I'm running a website that's uses a lot of rewrite rules created "on-the-fly" by a PHP script. When a .html document is requested, I use htaccess to parse the request to a PHP file.
RewriteRule ^(.*).html$ url_controller.php [L]
The url-controller.php contains the following code:
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;
I'm having a hard time seeing what I'm doing wrong - and even worse, I've started to consider whether Google could also be having trouble reaching my site?
I hope someone can aid me with their experience and knowledge :)
Thanks in advance
If you go to Google Webmaster Tools you will be able to fetch your page as GoogleBot. That will tell you if Google has a problem with it. Your code seems fine, but I did not take much time to look over it carefully.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.