.htaccess重定向到Drupal 7站点上的HTTP
我在从https重定向到http时遇到问题。我这样做的原因是服务器存在性能问题,因此在Apache上有一个缓存服务器(侦听端口80) 因此,为了减少负载,我想重定向所有没有cookie的请求(cookie只接受https),并且不将登录页面(/user)转到http 这是我的.htaccess文件,我删除了所有其他内容进行测试,没有进一步的重写规则。第三个重写规则来自Drupal,将所有请求发送到index.php.htaccess重定向到Drupal 7站点上的HTTP,.htaccess,mod-rewrite,drupal,.htaccess,Mod Rewrite,Drupal,我在从https重定向到http时遇到问题。我这样做的原因是服务器存在性能问题,因此在Apache上有一个缓存服务器(侦听端口80) 因此,为了减少负载,我想重定向所有没有cookie的请求(cookie只接受https),并且不将登录页面(/user)转到http 这是我的.htaccess文件,我删除了所有其他内容进行测试,没有进一步的重写规则。第三个重写规则来自Drupal,将所有请求发送到index.php <IfModule mod_rewrite.c> Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
# Rewrite http to https for /user.
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} =/user
RewriteRule ^ https://%{HTTP_HOST}/user [R=301,L]
#
# Rewrite https to http for anonymous.
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_COOKIE} !SSESS
RewriteCond %{REQUEST_URI} !=/user
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=307,L]
#
# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
</IfModule>
因此,如果第二条规则失败,它想用307重定向到/index.php?
有人知道为什么会这样吗
非常感谢,
mpj将第二条规则的URI条件更改为
RewriteCond %{THE_REQUEST} !\ /+user [NC]
您当前的规则是在随后的重写周期中重定向
index.php
。谢谢,这似乎有效。你知道为什么{REQUEST_URI}在这里不起作用吗?是的,重写index.php是正确的,它只是不应该使用重定向,因为index.php会丢失当前地址的信息(它正在处理所有请求)。当您上一次重写时,您可能认为它已经完成了,但不是,Apache会将index.php传递给另一个重写周期。在最后一个循环中,您的规则请求\u uri^/自从上次重写将其更改为index.php之后,用户匹配,现在您将获得307重定向。通过匹配_请求,我们避免了这个重写问题。
RewriteCond %{THE_REQUEST} !\ /+user [NC]