重写的.htaccess用于HTTPS [英] Rewrite .htaccess for https

查看:211
本文介绍了重写的.htaccess用于HTTPS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的HTTP站点.htaccess文件。我们的系统管理员所做的HTTPS设置,我可以让我的网站通过HTTPS。但问题是,我不能重写.htaccess文件。
例如:

I have an .htaccess file on my http site. Our system administrator made https settings and I can get my site by https. But the problem is that I can't rewrite .htaccess file. For example:

RewriteEngine On
Options -MultiViews
RewriteRule ^(index|getReadings|admin|adminNewDesign)\/([A-Za-z]*)$ $1.php?id=$2 [L,QSA,NC]

这适用于HTTP很好,但对HTTPS不起作用。
我想是这样的:

This works fine on http, but doesn't work on https. I tried like this:

RewriteEngine On
Options -MultiViews
RewriteCond %{HTTPS} On
RewriteRule ^(index|getReadings|admin|adminNewDesign)\/([A-Za-z]*)$ https://%{HTTP_HOST}/$1.php?id=$2 [L,QSA,NC]

和它不也行。如何正确地做呢?

And it doesn't work also. How to do it properly?

推荐答案

您目前只重定向当 HTTPS 标志的 ON ,这是显而易见的,不是你想要的。

You're currently redirecting only when the HTTPS flag is ON, which is obviously, not what you want.

Options -MultiViews
RewriteEngine On

RewriteCond %{HTTPS} off [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteRule ^(index|getReadings|admin|adminNewDesign)/([a-z]*)$ https://%{HTTP_HOST}/$1.php?id=$2 [L,QSA,NC]

这篇关于重写的.htaccess用于HTTPS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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