是否可以在war文件之外使用rewrite.properties和jboss-web.xml?
目前,我将两个文件都放在war文件中的WEB-INF中,并且可以按预期工作。但是(使用Maven的)集成测试将失败,因为它们将被重定向到真实的网站,而不是使用测试版本。
如果重要的话,我的域直接指向war文件的上下文路径。我正在使用JBoss 7.1.1。
我试图将两个文件都放在war文件旁边的服务器上,但这不起作用。
我将配置移动到standalone.xml(对于OpenShift用户,它位于folder内.openshift/config
)。关于用于URL重写的XML格式的文档很少,所以我将配置显示为示例代码。
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host"
native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<!-- Redirect all subdomains including naked domain to www subdomain. -->
<!-- RewriteCond %{HTTP_HOST} !^www\.example\.org$ [NC] -->
<!-- RewriteRule ^(.*)$ http://www.example.org/$1 [R=301,L] -->
<rewrite pattern="^(.*)$" substitution="http://www.example.org$1" flags="R=301,L">
<condition test="%{HTTP_HOST}" pattern="!^www\.example\.org$" flags="NC"/>
</rewrite>
<!-- Redirect from HTTP to HTTPS. -->
<!-- RewriteCond %{HTTP:X-Forwarded-Proto} http -->
<!-- RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L] -->
<rewrite pattern=".*" substitution="https://%{HTTP_HOST}%{REQUEST_URI}" flags="R,L">
<condition test="%{HTTP:X-Forwarded-Proto}" pattern="http" flags="NC"/>
</rewrite>
</virtual-server>
</subsystem>
也许可以优化这两个规则,但是我在重定向周期方面遇到了问题,这对我来说很有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句