GVKun编程网logo

Nginxredirect到Firefox中的非https地址失败(nginx referrer)

29

最近很多小伙伴都在问Nginxredirect到Firefox中的非https地址失败和nginxreferrer这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展.htaccess

最近很多小伙伴都在问Nginxredirect到Firefox中的非https地址失败nginx referrer这两个问题,那么本篇文章就来给大家详细解答一下,同时本文还将给你拓展.htaccess 301将所有httpsredirect到http EXCEPT ONE PAGE、.htaccess – 将httpredirect到https排除特定的url、.htaccess将httpredirect到https、.htaccess重写规则强制将httpsredirect到http等相关知识,下面开始了哦!

本文目录一览:

Nginxredirect到Firefox中的非https地址失败(nginx referrer)

Nginxredirect到Firefox中的非https地址失败(nginx referrer)

在目前正在使用HTTPS的网站上,我想将某些网页redirect到HTTP而不是使用SSL 。 在Nginx中我这样configuration:

server{ listen 80; server_name example.com; location / { root /var/some/where; } location /secure { return 301 https://example.com$request_uri; } } server{ listen 443 ssl; server_name example.com; include ssl_params; location /secure { root /var/some/where/secure; } location / { return 301 http://example.com$request_uri; } }

使用curl我可以看到一切都很好,如下所示:

$ curl -sIL https://example.com/ | grep HTTP HTTP/1.1 301 Moved Permanently HTTP/1.1 200 OK $ curl -sIL http://example.com/ | grep HTTP HTTP/1.1 200 OK

但是当我尝试在Firefox打开HTTPSurl时,会出现以下错误:

The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete. This problem can sometimes be caused by disabling or refusing to accept cookies

使用私人窗口,当我第一次尝试在HTTP打开URL时,是OK。 但是,一旦我刷新页面,它将被redirect到HTTPSscheme,错误将再次出现。

Nginxconfiguration,避免codeigniter重写规则

Docker容器遇到socket问题(单独的Flask + Nginx容器)

Moodle 2.0与Nginx的后端

在本地机器上的Ubuntu的Nginx。 致命错误:调用未定义的函数odbc_connect()

连接到上游时,Nginx – connect()失败(111:连接被拒绝)

502 Docker,NPM,PHPFPM和Symfony上的坏门

除了白名单,Nginx全部改写为index.PHP

在Nginx上运行json gem时融合乘客问题

如何使资产在Nginx的子目录中的Symfony3上运行

对django的urls.py的更改不反映在网上

你有证书吗? 没有显示在您的配置。

它的工作方式是打开安全连接(使用证书),然后返回内容(包括任何重定向)。 创建安全连接之前不可能重定向(因为如果可能的话,这对于https来说是一个巨大的安全风险)。

考虑Strict-Transport-Security: max-age=15768000作为目标域上的curl -i -L结果,这意味着hsts头存在并且按照定义:

告诉您的浏览器始终通过HTTPS连接到特定的域。 攻击者无法降级连接,用户不能忽略TLS警告。

.htaccess 301将所有httpsredirect到http EXCEPT ONE PAGE

.htaccess 301将所有httpsredirect到http EXCEPT ONE PAGE

这里是我目前在我的.htaccess文件中的代码:

Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301] RewriteEngine On RewriteCond %{HTTPS} on RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

我知道重写关于这个问题的所有其他post真的不符合我的标准,我不知道足够的语言来试图破译它。

基本上我需要的是这样的:

将“example.com”的所有实例redirect到“www.example.com”

将“ https //www.example.com”的所有实例redirect到“ http://www.example.com ” ,但1页除外 ! (万一它很重要,该页面的文件名是payments.PHP)

我有上面的代码工作,但对于我需要为HTTPS的1页,它是重写URL为http。 那一页必须是https。

Apacheredirect – .htaccess – ReWriteCond

为什么不.htaccess有什么作用?

我如何在.htaccess文件中定义variables并使用它?

如果不是带有apache的目录,则删除结尾的斜杠

将子文件夹redirect到root并将其隐藏在url中

谢谢,克里斯

如何在1and1共享主机上configurationCake 2.3.x的htaccess文件

如何在.htaccess中从一个子域redirect到另一个子域?

有子目录不使用Apache的.htaccess密码保护

在.htaccess中使用基于环境variables的RewriteCond

Apache从子域重写到www,但保留所有永久链接

Apache / 2.2.6(Win32)mod_ssl / 2.2.8 OpenSSL / 0.9.8g PHP / 5.2.6

我已经在本地进行了测试,所有用例似乎都正常工作。 如果您还有其他问题,请随时询问。

# Rewrite Rules for example.com RewriteEngine On RewriteBase / # Redirect from example.com to www.example.com RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] # Turn SSL on for payments RewriteCond %{HTTPS} off RewriteCond %{SCRIPT_FILENAME} /payments.PHP [NC] RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] # Turn SSL off everything but payments RewriteCond %{HTTPS} on RewriteCond %{SCRIPT_FILENAME} !/payments.PHP [NC] RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

重要! 当用户从带有www的任何https页面导航到没有 www的任何https页面时,他被要求接受你的非www域名的安全证书。

例如(YES =请求接受证书,NO – 反面):

1) https://www.asdf.com/payments.PHP - YES (www.asdf.com) 2) http://www.asdf.com/PHPinfo.PHP - NO 3) https://asdf.com/PHPinfo.PHP - YES (asdf.com) 4) https://www.asdf.com/PHPinfo.PHP - NO

我尝试在.htaccess中重新排序规则,但没有成功。 如果有人找到更好的解决方案,将不胜感激。

除了威廉姆斯的伟大的解决方案之外,你可以在https重写之前取消请求

RewriteCond %{REQUEST_URI} !^/?payments.PHP

这是一个很好的帖子,它似乎重定向到http,但我想要一些像下面的东西

RewriteCond %{HTTP_HOST} ^site.com RewriteRule (.*) http://www.site.com/$1 [R=301,L] #RewriteCond %{SERVER_PORT} !^443$ #RewriteRule ^products https://www.site.com/products/ [R=301,L] # disable SSL on pages other than payments.PHP RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^products RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L] # Require SSL on payments.PHP RewriteCond %{HTTPS} !on RewriteCond %{REQUEST_URI} ^products/?$ RewriteRule ^(.*)$ https://www.site.com/$1 [R=301,L] RewriteCond $1 !^(index.PHP|images|js|css|static|img|payment|robots.txt|blank.gif) RewriteRule ^(.*)$ index.PHP/$1 [L]

我的网址是http://www.sitename.com和尾随正斜杠是可选的,我需要的是,如果没有文本的产品在url中,那么它需要他http&#xFF1A://,如果有一个字符串产品在那么uri应该是https&#xFF1A://

如何做到这一点…当我试图这是一个循环…重定向循环。

我使用codeigniter框架的工作,我已经从url中删除index.PHP。

所以如果像http://sitename.com/products发生,那么我想它是https://sitename.com/products

如果没有在网址中的产品,那么它应该重定向到http://

# Rewrite Rules for example.com RewriteEngine On RewriteBase / # Redirect from example.com to www.example.com RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # disable SSL on pages other than payments.PHP RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !^payments.PHP$ RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] # Require SSL on payments.PHP RewriteCond %{HTTPS} !on RewriteCond %{REQUEST_URI} ^payments.PHP$ RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

我没有测试过,但类似的东西应该工作

编辑:更新

总结

以上是小编为你收集整理的.htaccess 301将所有httpsredirect到http EXCEPT ONE PAGE全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

.htaccess – 将httpredirect到https排除特定的url

.htaccess – 将httpredirect到https排除特定的url

如何将httpredirect到https排除特定的url?

http://www.example.com/* => https://www.example.com/* http://www.example.com/nonssl/* => http://www.example.com/nonssl/*

所以我使用.htaccess文件如下:

RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^/nonssl/ RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

但是,当我去http://www.example.com/nonssl/testfunc ,它转到https://www.example.com/index.PHP/nonssl/testfunc 。

提前致谢。

重写问题 – L(ast)不被尊重?

将/ ch-de /中的urlredirect到/ de /并使用?redirecturl 和“

Apache Mod-Rewrite Primers?

覆盖服务器上的.htaccess文件

如何阻止通过IP访问一组url模式?

.htaccessredirect仅适用于部分url

在Apache 1.3中使用htaccess作为root用户的子目录

IP范围.htaccess文件mod_rewite

redirect需要.htaccess帮助

删除index.PHP url重写.htaccess

对于这个问题,我没有找到正确的方法,只是描述所有的服务重定向从http到https。

RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} ^/$ [OR] RewriteCond %{REQUEST_URI} ^/test [OR] RewriteCond %{REQUEST_URI} ^/test1 [OR] RewriteCond %{REQUEST_URI} ^/test2 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index.PHP|images|css|fonts|js|robots.txt) RewriteRule ^(.*)$ index.PHP?/$1 [L]

我知道这只是不推荐的方式。 如果谁能解决这个问题,就连接我吧。 谢谢。

总结

以上是小编为你收集整理的.htaccess – 将httpredirect到https排除特定的url全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

.htaccess将httpredirect到https

.htaccess将httpredirect到https

我有一个旧的url(www1.test.net),我想redirect到https://www1.test.net

我已经在我的网站上实施并安装了我们的SSL证书。

这是我的旧文件.htaccess:

RewriteEngine On RewriteRule !.(js|gif|jpg|png|css|txt)$ public/index.PHP [L] RewriteCond %{REQUEST_URI} !^/public/ RewriteRule ^(.*)$ public/$1 [L]

我怎样才能configuration我的.htaccess文件,以便url自动redirect到https?

谢谢!

使用HTACCESS隐藏URL中的文件夹

防止在htaccess中redirect文件夹

.htaccess在多个环境中

将文件夹redirect到包含文件夹的子域

.htaccess通过虚拟主机的基本身份validation?

2016年更新

由于这个答案得到了一些关注,我想暗示一个更推荐的方式来做这个使用虚拟主机: Apache:重定向SSL

<VirtualHost *:80> serverName mysite.example.com Redirect permanent / https://mysite.example.com/ </VirtualHost> <VirtualHost _default_:443> serverName mysite.example.com DocumentRoot /usr/local/apache2/htdocs SSLEngine On # etc... </VirtualHost>

老回答,哈克东西给你的ssl端口没有设置为80,这将工作:

RewriteEngine on # force ssl RewriteCond %{SERVER_PORT} ^80$ RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

请注意,这应该是您的第一个重写规则。

编辑:此代码执行以下操作。 RewriteCond(ition)检查请求的serverPort是80(这是默认的http-port,如果你指定了另一个端口,则必须调整它的条件)。 如果是这样,我们匹配整个网址(.*)并将其重定向到https-url。 %{SERVER_NAME}可能会替换为特定的网址,但这种方式您不必更改其他项目的代码。 %{REQUEST_URI}是TLD(顶级域名)之后网址的一部分,因此您将被重定向到您来自的地方,而不是https。

我使用以下命令将我的域的所有页面从http重定向到https:

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

请注意,这将重定向使用301 ''permanently moved''重定向,这将有助于转移您的搜索引擎优化排名。

使用302 ''temporarily moved''改变重定向[R=302,L]

这对于www和https,代理而不是代理用户来说是最好的。

RewriteEngine On ### WWW & HTTPS # ensure www. RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # ensure https RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ### WWW & HTTPS

我用以下代码强制https:

RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

寻找重定向的最佳方法,我发现这(来自html5boilerplate):

# ---------------------------------------------------------------------- # | HTTP Strict Transport Security (HSTS) | # ---------------------------------------------------------------------- # Force client-side SSL redirection. # # If a user types `example.com` in their browser,even if the server # redirects them to the secure version of the website,that still leaves # a window of opportunity (the initial HTTP connection) for an attacker # to downgrade or redirect the request. # # The following header ensures that browser will ONLY connect to your # server via HTTPS,regardless of what the users type in the browser''s # address bar. # # (!) Remove the `includeSubDomains` optional directive if the website''s # subdomains are not using HTTPS. # # http://www.html5rocks.com/en/tutorials/security/transport-layer-security/ # https://tools.ietf.org/html/draft-ietf-websec-strict-transport-sec-14#section-6.1 # http://blogs.msdn.com/b/ieinternals/archive/2014/08/18/hsts-strict-transport-security-attacks-mitigations-deployment-https.aspx Header set Strict-Transport-Security "max-age=16070400; includeSubDomains"

也许这将在2017年帮助别人!

总结

以上是小编为你收集整理的.htaccess将httpredirect到https全部内容。

如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。

.htaccess重写规则强制将httpsredirect到http

.htaccess重写规则强制将httpsredirect到http

我有一个主域名https://www.domain.com或https://domain.com和像https://domain.com/index.PHP?name=abcd强制通过http://abcd.domain.comredirect的通配DNS http://abcd.domain.com但我有另一个问题,我的login页面是https://domain.com/login.PHP?name=abcd ,我想结果像强制http://domain.com/login.PHP?name=abcd但它不能在HTTP上redirect。

RewriteEngine On #match either the www subdomain or no subdomain RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ #which request index.PHP RewriteCond %{REQUEST_URI} ^/index.PHP #and contain a username paramater RewriteCond %{QUERY_STRING} ^(.*?)(?:^|&)name=([^&]+)(.*?)$ #then rewrite them to name.domain.com without the name parameter RewriteRule ^ http://%1.domain.com%{REQUEST_URI} [R,L] #match either the www subdomain or no subdomain RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ #which was requested without https RewriteCond %{HTTPS} off #then redirect to https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L] #Capture subdomain RewriteCond %{HTTP_HOST} ^([^.]+).(?:domain.com)$ #If we're not working on www RewriteCond %{HTTP_HOST} !^(?:www.domain.com)$ #If querystring doesn't contain name RewriteCond %{QUERY_STRING} !^(.*?)(?:^|&)name=([^&]+)(.*?)$ #Add username to querystring RewriteRule index.PHP index.PHP?name=%1 [L,QSA]

这个htaccess的代码工作正常,但我想login脚本在htaccess

在聊天澄清后,这是我所需要的:

所有的URL都应该被重写为https ,除了login.PHP ,它应该停留在http 。 如果login.PHP以https ,请将其重写为http 。

请求的资源.htaccess上不存在Access-Control-Allow-Origin标头

mod_rewrite不适用于Windows 7上的Apache 2.2

Apache .htaccess隐藏.PHP和.html扩展名

如何使mod_rewrite从子域redirect到查询string?

如果不是带有apache的目录,则删除结尾的斜杠

我怎样才能设置CORS访问我的Linux Web服务器上的audio文件与Apache2?

在htaccess中禁用PHP函数

多国使用.htacces

无法获取.htaccess mod_rewrite规则工作 – 404找不到

.htaccess:如果调用特定的目录,则重写整个URL

你已经有重写为https的规则,唯一剩下的就是不包括login.PHP

RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} !^/login.PHP$ RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

如果用 https请求login.PHP ,则将其重写为http

RewriteCond %{HTTP_HOST} ^(?:www.)?(?:domain.com)$ RewriteCond %{HTTPS} on RewriteRule ^login.PHP$ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

最后,一个小提示: 从不测试301启用,看到这个答案提示调试.htaccess重写规则的细节。

尝试这个 :

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

我们今天的关于Nginxredirect到Firefox中的非https地址失败nginx referrer的分享已经告一段落,感谢您的关注,如果您想了解更多关于.htaccess 301将所有httpsredirect到http EXCEPT ONE PAGE、.htaccess – 将httpredirect到https排除特定的url、.htaccess将httpredirect到https、.htaccess重写规则强制将httpsredirect到http的相关信息,请在本站查询。

本文标签: