mod_rewrite的所有重定向到https,除了一个文件 [英] mod_rewrite redirect all to https except one file

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

问题描述

我用这个code

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

重定向所有请求,HTTPS,这是好的。

to redirect all request to HTTPS and that is ok.

现在我想除了一个文件index810.php同样的事情

Now I want same thing except one file index810.php

当我这样写

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^ index810.php
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}  

我得到过多的重定向,任何建议。

i get too many redirects, any suggestions.

感谢您提前

推荐答案

A 解决方案是使用非重写规则:

A solution is to use a non rewriting rule:

# do nothing for /index810.php
RewriteRule ^index810\.php$ - [L]
# else ...
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}

您的模式是错的:


  • 有^和index810.php
  • 之间有一个空格
  • %{REQUEST_URI}是所有的HTTP路径(即,如果在文档根目录,这将是 = / index810.php

  • there is a space between ^ and index810.php
  • %{REQUEST_URI} is all the HTTP path (ie, if at document root, it would be =/index810.php)

这篇关于mod_rewrite的所有重定向到https,除了一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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