Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 301 htaccess重定向除现有页面外的所有内容_.htaccess_Redirect_Forward - Fatal编程技术网

.htaccess 301 htaccess重定向除现有页面外的所有内容

.htaccess 301 htaccess重定向除现有页面外的所有内容,.htaccess,redirect,forward,.htaccess,Redirect,Forward,我想在同一台服务器上从http移动到https。所有页面、文件等都需要转发到https,只有四个页面使用iFrame嵌入在多个网站上。由于https不能包含在iframe中,因此我想保留它们,但添加其他所有内容 我现在在htaccess上玩了一个多小时,但没有成功。最新的试验如下。但是在这个例子中,我需要自己写下这些文件。我想将http服务器上不存在的所有内容转发到https服务器,其余部分保持原样 RewriteCond %{HTTPS} = off RewriteCond $1 !^(ins

我想在同一台服务器上从http移动到https。所有页面、文件等都需要转发到https,只有四个页面使用iFrame嵌入在多个网站上。由于https不能包含在
iframe
中,因此我想保留它们,但添加其他所有内容

我现在在htaccess上玩了一个多小时,但没有成功。最新的试验如下。但是在这个例子中,我需要自己写下这些文件。我想将
http
服务器上不存在的所有内容转发到
https
服务器,其余部分保持原样

RewriteCond %{HTTPS} = off
RewriteCond $1 !^(inschrijven-frame|inschrijven-frame2)\.php$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ https://www.url.nl/$1 [R=301,L]
需要做的是:

  • 如果文件位于http上,请打开它
  • 如果文件不在http上,则转到https,因此自动变为
  • 在2上找不到的页面应通过https转发到de main域

  • 我想我解决了。这样行吗

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{SERVER_PORT} 443
    RewriteRule ^(page1|page2|test1|test2)\.php$1 [R,L]
    
    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{REQUEST_URI} !^/ipage
    RewriteCond %{REQUEST_URI} !^/test
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    

    @如果你发布一个答案,我可以接受。

    1)这一行是错误的
    RewriteCond%{HTTP}=on
    --应该是
    RewriteCond%{HTTPS}=off[NC]
    2)你使用了错误的字符或正则表达式逻辑--应该是
    而不是
    。谢谢LazyOne,如果http文件存在,您是否也建议不要转到https?使用以下命令:
    RewriteCond%{REQUEST_FILENAME}-f
    。解释/文档在这里:我感谢您的帮助,但它不起作用,请参阅更新的帖子。@LazyOne如果您发布答案,我可以接受。