.htaccess 不让 robots.txt 通过

标签 .htaccess robots.txt

我的根目录中有以下 .htaccess 文件:

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]
RewriteRule ^([^/]*)$ index.php?page=$1 [NC]

这适用于将我所有的 URL 缩短到 website.com/something

问题是 Google 在我的根目录中找不到我的 robots.txt 文件。上面的文件没有让它通过。当它输入 website.com/robots.txt 时,我得到一个 404 未找到。但是如果我注释掉上面的 .htaccess 代码,我就可以很好地完成它。

如何编辑我的 .htaccess 文件以让 robots.txt 通过而不干扰我的其他 URL?

最佳答案

RewriteEngine on
RewriteRule ^robots.txt - [L]
第二行将从 URL 重写规则中排除 robots.txt。
试试上面的代码

关于.htaccess 不让 robots.txt 通过,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9546032/

相关文章:

php - htaccess 使用 mod_rewrite 重定向 seo 友好的 url

.htaccess 使用 %20 将所有 url 重定向到 -

php - Robots.txt 和元数据标记是否足以阻止搜索引擎索引依赖于 $_GET 变量的动态页面?

linux - 防止从 Node.js 应用程序直接访问 Url

python - 在共享虚拟主机上将 Flask 部署为 CGI

css - 没有 www 就不会出现 webfont

seo - Robots.txt,加密字符?不允许 :/azr94v2hh2lg/

python - 关于 robots.txt 的问题,禁止不带冒号

coldfusion - Robots.txt 和 Coldfusion

robots.txt - 将 Robots.txt 放在 Blazor Web Assembly 项目中的最佳位置在哪里?