Apache .htaccess重定向除少数URL外的所有URL
所以,基本上,我有以下。htaccessApache .htaccess重定向除少数URL外的所有URL,apache,.htaccess,redirect,iframe,Apache,.htaccess,Redirect,Iframe,所以,基本上,我有以下。htaccess RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/online$ RewriteRule (.*)$ https://secure.example.com/$1 [R=301,L] 但它不起作用: http example.com/online被重定向到https secure.example.com 我想要的是: http example.com->http
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/online$
RewriteRule (.*)$ https://secure.example.com/$1 [R=301,L]
但它不起作用:
http example.com/online被重定向到https secure.example.com
我想要的是:
http example.com->https secure.example.com
http example.com/foo/->https secure.example.com/foo/
http example.com/online/->http example.com/online/no重定向
这是因为在example.com/online上我有一个iframe,src不在HTTPS上。
另一种方法是强制浏览器在页面上显示非https数据。现在我有一个空页面,因为iframe被浏览器阻止了。您可以在根文件夹中的htaccess中将当前代码替换为此代码
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^secure\. [NC]
RewriteCond %{REQUEST_URI} !^/online [NC]
RewriteRule ^(.*)$ https://secure.example.com/$1 [R=301,L]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^secure\. [NC]
RewriteRule ^online(/.*)?$ http://example.com/online$1 [R=301,L]
第一条规则重定向到https://secure 如果它是http或域而不是以secure ready开头,并且url不是/online/A或B和C,则等效
第二条规则将联机/重定向到http://example.com/online/ 如果是https或域,则以安全开头。。。。似乎不起作用。也许问题出在我身上。。。那么,让我们进一步解释:1。安全子域具有不同的.htaccess文件;2.它还应该适用于/online/foo/、/online/boo/,等等3。为了让框架得到这个结果,我使用RewriteCond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-重写规则^.*$index.php?/$1[L]对于您的第一点,安全htaccess中有什么?对于第二点,我编辑了我的答案,使其有效。对于第三点,必须将我的代码放在框架规则之前