Can robots reach my site? Facebook can't! Custom URL controller in PHP
<p>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 <a href="http://www.domainname.com/categories/blouses.html" rel="nofollow">http://www.domainname.com/categories/blouses.html</a> could not be reached."</p>

<p>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.</p>

<pre><code>RewriteRule ^(.*).html$  url_controller.php [L]
</code></pre>

<p>The url-controller.php contains the following code:</p>

<pre><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 &amp;&amp; sp.shop_id = ".$GLOBALS['site_id']." WHERE pl.url_key = '{$url}' &amp;&amp; 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 &amp;&amp; sc.shop_id = ".$GLOBALS['site_id']." INNER JOIN category_languages AS cl ON cl.category_id = c.id &amp;&amp; cl.url_key = '{$parent}' &amp;&amp; cl.locale = '{$_SESSION['language']}' WHERE parent = 1 &amp;&amp; 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 &amp;&amp; sc.shop_id = ".$GLOBALS['site_id']." INNER JOIN category_languages AS cl ON cl.category_id = c.id &amp;&amp; cl.url_key = '{$child}' &amp;&amp; cl.locale = '{$_SESSION['language']}' WHERE parent = 0 &amp;&amp; active = 1 LIMIT 0,1");
if(mysql_num_rows($get_parent) &amp;&amp; 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']." &amp;&amp; old_url = '".str_replace('Webshop/','',$url)."' &amp;&amp; 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;
</code></pre>

<p>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?</p>

<p>I hope someone can aid me with their experience and knowledge :)</p>

<p>Thanks in advance</p>
