保持HTTP或HTTPS上的.htaccess [英] Keep HTTP or HTTPS on .htaccess

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

问题描述

我有以下的的.htaccess 文件:

RewriteEngine On 
RewriteCond %{REQUEST_URI} /api/profile/
RewriteRule ^(.*)$ http://whatsee-profile.s3.amazonaws.com/$1 [R,L]

重定向我的假链接来以假乱真伟大工程!但我需要保持原有的 HTTP HTTPS 的协议的URL之前。我已经试过以下,但它不能正常工作。

It redirects my fake links to the real ones and works great! But I need to keep the original HTTP or HTTPS protocol before the url. I've tried the following, but it doesn't work.

RewriteEngine On 
RewriteCond %{REQUEST_URI} /api/profile/
RewriteRule (http|https):\/\/whatsee.plugapps.net\/api\/profile\/(.*) $1://whatsee-profile.s3.amazonaws.com/$2 [R,L]

任何想法有什么不好?感谢您的帮助!

Any idea what is wrong? Thanks for your help!

推荐答案

它的存在做这件事的几种方法。
这里有一个可行的解决方案。

It exists several ways of doing it.
Here is one working solution

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteRule ^ - [env=protoc:https]
RewriteCond %{HTTPS} off
RewriteRule ^ - [env=protoc:http]

RewriteCond %{REQUEST_URI} /api/profile/
RewriteRule ^(.*)$ %{ENV:protoc}://whatsee-profile.s3.amazonaws.com/$1 [R,L]

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

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