我有一个系统,我在我的服务器上托pipe一些SSL站点。 我还需要为每个域设置OAuth,尤其是Google和Yahoo。 他们每个都需要在服务器上安装validation文件,以validation所有权。 现在有这么多的文件,他们堵塞我的根目录。 所以我想要设置一个重写规则来发送一个请求到一个特定的URL到一个validation文件目录,如下所示:
RewriteRule (^/googlew*.html$) /verifications$1
这会向http://server/verifications/google27c81d94580e55dd.html发送Googlevalidation文件请求,例如http://server/google27c81d94580e55dd.html ,而且不会重写url,它可以正常工作。
但是,当请求转到SSL URL时,它会失败。 这是我的configuration:
<VirtualHost *:80> ServerName <domain> DocumentRoot /www/public RewriteEngine On RewriteRule (^/googlew*.html$) /verifications$1 [R] RewriteRule (^.*--.html$) /verifications$1 [R] </VirtualHost> <VirtualHost <ipaddress>:443> SSLEngine On ServerName <domain> DocumentRoot /www/public RackEnv production RewriteEngine On RewriteRule (^/googlew*.html$) /verifications$1 [R] RewriteRule (^.*--.html$) /verifications$1 SSLProtocol all SSLCipherSuite HIGH:MEDIUM SSLCertificateChainFile /usr/share/ssl/crt/intermediate.crt SSLCertificateFile /usr/share/ssl/crt/<domain>/<domain>.crt SSLCertificateKeyFile /usr/share/ssl/crt/<domain>/<domain>.key </VirtualHost>
所以当请求是不安全的HTTP,它工作正常。 当它是安全的HTTPS时,它会失败。 有什么build议,为什么?
更新根据要求,这里是3级重写日志的输出:
init rewrite engine with requested uri /google27c81d94580e55dd.html applying pattern '(^/googlew*.html$)' to uri '/google27c81d94580e55dd.html' applying pattern '(^.*--.html$)' to uri '/google27c81d94580e55dd.html' pass through /google27c81d94580e55dd.html
现在,这是有趣的事情:在我原来的职位之前,正如我所说的非安全版本工作正常。 我发布后,非安全版本也停止工作! 我刚刚粘贴的日志条目是我在运行非安全版本时得到的。 面对。 爆炸。
一些东西:
^和$ 。 \w* ,而不是w* ; 这将匹配这些字符。 所以,试试这个:
RewriteRule ^(/google\w*\.html)$ /verifications$1 [R]
我没有遵循你的第二条规则的意图。 你能澄清吗?