2014-10-06 61 views
2

我有以下的.htaccess文件保持HTTP或HTTPS上的.htaccess

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

redirects my fake links到以假亂真偉大工程!但我需要在url之前保留原始的HTTPHTTPS協議。我試過以下,但它不起作用。

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

任何想法是什麼錯?謝謝你的幫助!

回答

1

它存在幾種做法。
這是一個可行的解決方案

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] 
+1

偉大的作品,感謝@JustinIurman! – bodruk 2014-10-06 18:44:57