将机器人重定向到站点的静态版本
Redirect bots to static version of site
基本上,我想使用 .htaccess 文件将机器人从常规站点重定向到静态版本。
情况如下:
URL我站点中的文件格式如下:
http://example.com/?p=something
http://example.com/index.html?p=something
http://example.com/basic.php?p=something
并且我想使用 .htaccess 文件通过将 index.html 替换为 basic.php 或如果不存在则添加它。根也应该变成 basic.php 而不是 index.html.
这是我当前的 .htaccess 文件,这是错误的,因为它只有在 URL 包含 index.html
时才有效
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (googlebot|InfoSeek|msnbot|bingbot|Slurp|DuckDuckBot) [NC]
RewriteRule ^index\.html$ /basic.php [L,R]
如果有好心人能帮我解决这个问题,将不胜感激。谢谢
http://example.com/?p=something
http://example.com/index.html?p=something
要匹配这两者中的任何一个,您只需将模式(即 URL 路径)设为可选:
RewriteRule ^(index\.html)?$ /basic.php [L,R]
旁白:从 SEO 的角度来看,这有点可疑。它可能被视为 "cloaking" - 向搜索引擎提供的内容与向用户提供的内容不同,这可能会产生负面影响。搜索引擎显然希望为您的静态站点(被重定向到的页面)编制索引,而不是 "users" 看到的站点。
基本上,我想使用 .htaccess 文件将机器人从常规站点重定向到静态版本。
情况如下: URL我站点中的文件格式如下:
http://example.com/?p=something
http://example.com/index.html?p=something
http://example.com/basic.php?p=something
并且我想使用 .htaccess 文件通过将 index.html 替换为 basic.php 或如果不存在则添加它。根也应该变成 basic.php 而不是 index.html.
这是我当前的 .htaccess 文件,这是错误的,因为它只有在 URL 包含 index.html
时才有效RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (googlebot|InfoSeek|msnbot|bingbot|Slurp|DuckDuckBot) [NC]
RewriteRule ^index\.html$ /basic.php [L,R]
如果有好心人能帮我解决这个问题,将不胜感激。谢谢
http://example.com/?p=something
http://example.com/index.html?p=something
要匹配这两者中的任何一个,您只需将模式(即 URL 路径)设为可选:
RewriteRule ^(index\.html)?$ /basic.php [L,R]
旁白:从 SEO 的角度来看,这有点可疑。它可能被视为 "cloaking" - 向搜索引擎提供的内容与向用户提供的内容不同,这可能会产生负面影响。搜索引擎显然希望为您的静态站点(被重定向到的页面)编制索引,而不是 "users" 看到的站点。