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 重定向到HTTPS,1页除外_.htaccess_Mod Rewrite_Redirect_Https - Fatal编程技术网

.htaccess 重定向到HTTPS,1页除外

.htaccess 重定向到HTTPS,1页除外,.htaccess,mod-rewrite,redirect,https,.htaccess,Mod Rewrite,Redirect,Https,我一直在到处寻找答案,但没有找到能解决我问题的答案。 我正在使用以下.htaccess文件将用户从站点重定向到其https版本: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !=on # This checks to make sure the connection is not already HTTPS # RewriteCond %{REQUEST_URI} !^/api-vop/ Rewrit

我一直在到处寻找答案,但没有找到能解决我问题的答案。 我正在使用以下.htaccess文件将用户从站点重定向到其https版本:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
# RewriteCond %{REQUEST_URI} !^/api-vop/
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
问题是我无法让它工作,充其量我只能返回index.php页面

有什么解决办法吗


提前谢谢

遵守第一条规则:

RewriteCond %{HTTPS} off
# This checks to make sure the connection is not already HTTPS
# RewriteCond %{THE_REQUEST} !\s/+api-vop/
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L,NE]

_REQUEST
变量表示Apache从浏览器收到的原始请求,在执行某些重写规则后不会被覆盖。此变量的示例值为
GET/index.php?id=123 HTTP/1.1

您好,谢谢您的回答。恐怕你把我弄丢了,因为有两件事:你的请求和最后一行的NE。你能不能把我应该用的那句话发出去?还有一个非php文件名为,但我在这里提供的一个符号url是my-server.com/api-vopRule,这是您需要使用的。您需要用此规则替换第一条规则,即
RewriteBase/
上面的所有行。
RewriteCond %{HTTPS} off
# This checks to make sure the connection is not already HTTPS
# RewriteCond %{THE_REQUEST} !\s/+api-vop/
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L,NE]