其中redirect永久规则需要添加

我想redirect我的网站http请求到https我的网站是

https://开头testing

我的apache版本是2.4,而ssl configration是(ssl.conf)在httpd.conf的单独文件中,我没有使用.htaccess文件,所以我应该追加。 我已经试过这两个文件,但没有工作。

redirect永久/ https://testing

是应该在我的httpd.conf或ssl.conf或我错过了别的东西。 我更喜欢重写重写。

Rewrite.log

10.10.86.1 – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](2)init请求的uri / error /HTTP_BAD_REQUEST.html.var

10.10.86.1 – – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](3)应用模式'^(。*) $'to uri'/error/HTTP_BAD_REQUEST.html.var'

10.10.86.1 – – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](4)RewriteCond:input ='off'pattern ='!= on'=>匹配

10.10.86.1 – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](2)重写/error/HTTP_BAD_REQUEST.html。 var – > * ttps://test/error/HTTP_BAD_REQUEST.html.var [QSA,R = 301,L]

10.10.86.1 – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](2)隐式强制redirect(rc = 302)与* ttps://test/error/HTTP_BAD_REQUEST.html.var [QSA,R = 301,L]

10.10.86.1 – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](1)转义* ttps:// test /错误/ HTTP_BAD_REQUEST.html.var [QSA,R = 301,L]redirect

10.10.86.1 – [05 / Apr / 2012:15:10:19 – 0700] [test / sid#7ce00] [rid#277448 / initial / redir#1](1)redirect到* ttps:// test /error/HTTP_BAD_REQUEST.html.var%5bQSA,R=301,L%5d [REDIRECT / 302]

由于您同时使用HTTP和HTTPS,因此您正在使用虚拟主机。

该指令应该放在80端口的<VirtualHost>块中。

您需要两个虚拟主机configuration才能在80上侦听,另一个侦听443上的SSL。 你应该把它放在你的虚拟主机标签里面的NON-SSL站点。 然后像正常一样configuration您的SSL虚拟主机(在ssl.conf中)。

 Listen 12.34.56.78:80 <virtualhost 12.34.56.78:80> Blah some more config stuff DocumentRoot /var/www/null redirect permanent / https://test/ </virtualhost> 

只要注意目标站点上的斜线,如果你没有插入http://test/index.php,你的configuration会把它们发送到https://testindex.php存在。