将 https 提供的所有数据重定向到 http [英] Redirect all the data served by https to http

查看:69
本文介绍了将 https 提供的所有数据重定向到 http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,情况是这样的:

我们正在运营一个由 Drupal 提供支持的网站.前一段时间,决定该网站应作为 SSL 使用.将站点从 http 重定向到 https 的设置是由一个不再与我们在一起的人完成的.

We are running a website which is powered by Drupal. Sometime ago, it was decided that the website should be served as SSL. The settings to redirect the site from http to https was done by a guy who is not with us anymore.

我可以在 .htaccess 文件中看到以下几行

I can see in the .htaccess file the following lines

#Redirect http to https
RewriteEngine On  
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://docs.dev.domain.com/$1 [R,L]

mydomain.com 指向 LAMPP 服务器的根目录,我的站点位于 webroot (docs.dev.domain.com/mysite) 内的文件夹中.

mydomain.com points to the root of the LAMPP server and my site is in a folder inside the webroot (docs.dev.domain.com/mysite).

现在,已决定不需要 SSL,必须将其删除,并且所有页面都必须通过 http(301 重定向)提供服务.

Now, it has been decided that the SSL is not needed and it has to be removed and all the pages must be served via http (301 redirect).

当我在 .htaccess 文件中使用 RewriteRule 重定向 URL(例如 https://docs.dev.domain.com/mysite/content/book) 在用户访问 https 时使用 http:

When I do that in the .htaccess file by using the RewriteRule to redirect a URL (e.g. https://docs.dev.domain.com/mysite/content/book) to http when a user visits https by using:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]


#Redirect HTTPS to HTTP
RewriteCond %{SERVER_PORT} ^443$
#RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://docs.dev.domain.com/mysite/$1 [R=301,L]
#even tried this - RewriteRule ^(.*)$ http://docs.dev.domain.com/$1 [R=301,L]

但它将 https 上的每个请求重定向到 http://mydomain.com/mysite/index.php(即使是像 (https://docs.dev.domain.com/mysite/content/book/1 这样的 url,理想情况下应该重定向到它的 http 对应部分).

but it redirects every request on https to http://mydomain.com/mysite/index.php (even the urls like (https://docs.dev.domain.com/mysite/content/book/1 which should ideally be redirected to its http counterpart).

如何删除 https 以便通过普通 http 提供我的动态 URL?很抱歉,如果这是非常新手的问题.

How can I remove the https so that my dynamic URLs are served via plain http? Sorry if this is very novice problem.

推荐答案

发生这种情况是因为您在重定向之前有一个路由规则.重写引擎将循环直到 URI 返回不变,然后,它会评估是否需要将 URI 传递到其他模块以处理重定向或代理.

This is happening because you have a routing rule before the redirect. The rewrite engine will loop until the URI comes back unchanged, and at that point, it evaluates if the URI needs to be passed onto other modules in order to handle redirecting or proxying.

这意味着您的请求被路由到 index.php,然后重写引擎循环,然后它看到请求(此时只是 /index.phpcode>) 需要被重定向,所以请求被标记为被重定向.然后 mod_rewite 重定向,但现在,URI 已被您的路由规则破坏.

That means your request is getting routed to index.php, then the rewrite engine loops, then it sees that the request (which at this point is simply /index.php) needs to be redirected, so the request gets flagged to be redirected. Then mod_rewite redirects, but by now, the URI is mangled by your routing rule.

您需要交换订单:

RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://docs.dev.domain.com/mysite/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

这篇关于将 https 提供的所有数据重定向到 http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆