我需要通过/gapp
和http and https
之类的其他网址以及其他网址/aapp, /bapp, /capp
来路由特定网址https
。我已成功将所有内容路由到https,但无法将/gapp
路由到http。以下是我的配置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} =on
RewriteRule ^(gapp)$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
</IfModule>
# Should mod_jk send SSL information to Tomcat (default is On)
JkExtractSSL On
# What is the indicator for SSL (default is HTTPS)
JkHTTPSIndicator HTTPS
# What is the indicator for SSL session (default is SSL_SESSION_ID)
JkSESSIONIndicator SSL_SESSION_ID
# What is the indicator for client SSL cipher suit (default is SSL_CIPHER)
JkCIPHERIndicator SSL_CIPHER
# What is the indicator for the client SSL certificated (default is SSL_CLIENT_CERT)
JkCERTSIndicator SSL_CLIENT_CERT
# Send everything for context /examples to worker named worker1 (ajp13)
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
JkMount /aapp aapp
JkMount /bapp/* bapp
JkMount /capp capp
JkMount /gapp gapp
JkMount /gapp/* gapp
简单来说,我希望能够做到这些:
http://example.com/gapp/
https://example.com/gapp/
我如何做到这一点?
答案 0 :(得分:1)
我相信您正在寻找与此相同的答案:.htaccess - htaccess redirect 4 specific pages
如果您想访问除https和http之外的其他所有内容,最好不要重定向,但只需对URL进行重写,如果匹配则将其重定向到https:
#force https for certain pages
RewriteCond %{REQUEST_URI} !^/gapp
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]