apache 将 HTTPS 重定向到 HTTP

apache 将 HTTPS 重定向到 HTTP

当我们使用这个简单的代码进行重定向时,我正在使用这个 htaccess 代码将我的 https terrafic 重定向到 http,一切都很好,但它破坏了网站的搜索引擎链接。该网站有来自谷歌的访问者到这个链接 domain.com/search/?q=jim 并将其转换为 domain.com/search/?q= 并且 jim 关键字丢失了。

RewriteEngine on
RewriteRule ^category/(.*)/(.*)$ category.php?id=$1&slug=$2
RewriteRule ^source/(.*)/(.*)$ source.php?id=$1&slug=$2
RewriteRule ^news/(.*)/?$ news.php?id=$1&slug=$2
RewriteRule ^page/(.*)/(.*)$ page.php?id=$1&slug=$2
RewriteRule ^search/(.*)$ search.php?q=$1
RewriteRule ^not-found$ notfound.php [G,L]
RewriteRule ^rss.xml$ rss.php
RewriteRule ^lasttagmap.xml$ lasttagmap.php
RewriteRule ^randtagmap.xml$ randtagmap.php
RewriteRule ^sitemap-(.*).xml$ sitemap.php?id=$1
RewriteRule ^categories-sitemap.xml$ categories-sitemap.php
Options +FollowSymLinks


RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

答案1

对于类似的其他请求也应该如此。例如,如果您访问,则/source/x/y?value=something最后一点应该会丢失。您缺少查询字符串。

文档这表明你需要[QSA]在重写中添加一个标志。问题Mod_rewrite:重定向时包含查询字符串也会建议这样做。

相关内容