谷歌网站的索引服务器文件路径


Google indexing server file path of website?

我最近完成了一个网站的构建,在试图让谷歌为网站建立索引时,我似乎遇到了一些奇怪的事情,我希望有人能对此有所了解,因为我的谷歌功能没有透露任何信息。

我正在运行的服务器堆栈由以下部分组成:

Debian 7 / Apache 2.2.22 / MySQL 5.5.31 / PHP 5.4.4-14

我遇到的问题是,谷歌似乎想索引一些奇怪的URL,并且目前对它们的排名高于实际的合法页面。我会在这里列出奇怪的:

www.mydomain.com/srv/www/mydomain?srv/www/mydomain
www.mydomain.com/srv/www?srv/www
www.mydomain.com/srv/www?srv/www/index‎

Webmaster工具现在告诉我"这是一个被robots.txt阻止的重要页面",因为我一发现问题,就将一些301重定向放入htaccess文件,将这些请求发送到主页,并阻止robots文件中的地址。

此外,我已经向网站管理员工具提交了一个包含所有正确URL的XML网站地图。

所有网站文件都存储在:

/srv/www/mydomain/public_html/

现在,我认为这与我设置.htaccess mod重写规则的方式有关,但我似乎无法理解是什么在做。这也可能是我的Apache vhosts配置。我将包括以下两者:

.htaccess mod-rewrite规则:

<IfModule mod_rewrite.c>
    RewriteEngine on
# Redirect requests for all non-canonical domains
# to same page in www.mydomain.com
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www'.mydomain'.com$
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]

# Remove .php file extension
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}'.php -f
    RewriteRule ^(.*)$ $1.php
# redirect all traffic to index
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index [L]
# Remove 'index' from URL
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s(.*)/index [NC]
    RewriteRule ^ / [R=301,L]
</IfModule>

Apache Vhost:

<VirtualHost *:80>
    ServerAdmin webmaster@mydomain.com
    ServerName mydomain.com
    ServerAlias www.mydomain.com
    DocumentRoot /srv/www/mydomain/public_html/
    ErrorLog /srv/www/mydomain/logs/error.log
    CustomLog /srv/www/mydomain/logs/access.log combined
</VirtualHost>

此外,如果它可能是相关的,我的PHP页面处理是:

# Declare the Page array
$Page = array();
# Get the requested path and trim leading slashes
$Page['Path'] = ltrim($_SERVER['REQUEST_URI'], '/');
# Check for query string
if (strpos($Page['Path'], '?') !== false) {
    # Seperate path and query string
    $Page['Query']  = explode('?', $Page['Path'])['1'];
    $Page['Path']   = explode('?', $Page['Path'])['0'];
}
# Check a path was supplied
if ($Page['Path'] != '') {
    # Select page data from the directory
    $Page['Data'] = SelectData('Directory', 'Path', '=', $Page['Path']);
    # Check a page was returned
    if ($Page['Data'] != null) {
        # switch through allowed page types
        switch ($Page['Data']['Type']) {
            # There are a bunch of switch cases here that
            # Determine what page to serve based on the
            # page type stored in the directory
        }
    # When no page is returned
    } else {
        # 404
        $Page = Build404ErrorPage($Page);
    }
# When no path supplied
} else {
    # Build the Home page
    $Page = BuildHomePage($Page);
}

有人能在这里看到导致这一切的原因吗?

经过大量研究,我得出结论,我的问题是由于谷歌试图在网站完成之前对其进行索引,以及一些不完整的页面处理脚本造成的。我的错误是在开发过程中没有阻止所有的机器人。

问题的解决方案是:

  1. 向谷歌网站管理员工具提交xml站点地图以及所有有效URL的

  2. 301将所有奇怪的URL重定向到正确的主页

  3. 使用谷歌网站管理员工具请求删除不正确的URL

  4. 使用robots.txt文件阻止谷歌机器人访问不正确的URL

  5. 等待谷歌重新抓取网站并正确索引。

等待谷歌机器人来纠正这些问题是最困难的部分。