首页 > 解决方案 > 未找到 Ads.txt - 为 https 重定向正确配置 htaccess

问题描述

我试图让 Google 找到我的 ads.txt 文件。

目前我在尝试通过 HTTP 访问它时遇到问题(404 错误):

但是在 https 上它工作正常:

我认为我的 .htaccess 文件一定有问题,目前该文件内容如下:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule ^ https://leblonblue.com%{REQUEST_URI} [R=301,L,NE]

任何帮助将不胜感激

谢谢!

- 编辑

按照 CBroe 的建议,在其他内容之前放置重定向

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule ^ https://leblonblue.com%{REQUEST_URI} [R=301,L,NE]

RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

标签: .htaccesshttpshttp-redirect

解决方案


正如 CBroe 建议的那样,问题实际上出在我的服务器配置上。

我从 htaccess 中删除了重定向规则,并修复了我的负载均衡器以正确路由 http。


推荐阅读