Apache mod_rewrite使用302而不是https重定向到http

Apache mod_rewrite使用302而不是https重定向到http,apache,mod-rewrite,http-status-code-301,http-status-code-302,Apache,Mod Rewrite,Http Status Code 301,Http Status Code 302,在Apache2.2中,我使用mod_rewrite,我有一个重写规则- RewriteCond %{REQUEST_URI} ^/?mysite/? RewriteRule (.*)mysite/(.*) $1$2 [R=301,L] 这将重写此url- https://www.domain.com/mysite/about/ 到 这条规则似乎有效。但是当我在chrome开发者工具或httpwatch中看到网络跟踪时,我可以看到使用http协议302的重定向。跟踪如下(我已从跟踪中删除计时

在Apache2.2中,我使用mod_rewrite,我有一个重写规则-

RewriteCond %{REQUEST_URI} ^/?mysite/?
RewriteRule (.*)mysite/(.*) $1$2 [R=301,L]
这将重写此url-

https://www.domain.com/mysite/about/

这条规则似乎有效。但是当我在chrome开发者工具或httpwatch中看到网络跟踪时,我可以看到使用http协议302的重定向。跟踪如下(我已从跟踪中删除计时,并仅复制重定向)

我想避免302重定向到http://...... 根据我的重写规则,进行301重定向。有办法做到这一点吗?

第一个重定向(您所说的重定向)按预期工作,并使用301将用户发送到新页面。但是,您使用的系统似乎在URI的末尾强制使用“/”,并因此执行另一个重定向

也许像这样的方法会更好:

RewriteCond %{REQUEST_URI} ^/?mysite/?
RewriteRule (.*)mysite/(.*)/? https://www.example.com/$1$2/ [R=301,L]

但是你的追踪显示了4个重定向。。。我不太清楚为什么会有额外的2个重定向。

谢谢,调整了规则,并结合了一些条件,我能够解决额外的重定向。但为了解决不断变化的协议问题,我不得不强制重定向到https。重写规则(.*)mysite/(.*)/?https://$1$2/[R=301,L]Ah!对很抱歉,丢失了协议。我很高兴你成功了。
GET 301 Redirect to http://www.domain.com/about     https://www.domain.com/mysite/about
GET 302 Redirect to https://www.domain.com/about    http://www.domain.com/about
GET 302 Redirect to http://www.domain.com/about/    https://www.domain.com/about
GET 302 Redirect to https://www.domain.com/about/   http://www.domain.com/about/
GET 200 html    https://www.domain.com/about/
RewriteCond %{REQUEST_URI} ^/?mysite/?
RewriteRule (.*)mysite/(.*)/? https://www.example.com/$1$2/ [R=301,L]