.htaccess 重定向到HTTPS,1页除外
我一直在到处寻找答案,但没有找到能解决我问题的答案。 我正在使用以下.htaccess文件将用户从站点重定向到其https版本:.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
<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]