问题
I have a requirement to route a particular url, /gapp
via http and https
and other urls like /aapp, /bapp, /capp
and the rest via https
. I have succeded in routing everything to https but can't route /gapp
to http. Below is my configuration:
<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
In simple words, I want to be able to do these:
http://example.com/gapp/
https://example.com/gapp/
How do I accomplish this?
回答1:
I believe you are looking for the same answer as this: .htaccess - htaccess redirect 4 specific pages
If you want to access everything other then a few urls on https and http, you would be better not to redirect however just make a rewrite condition for the URLs and if they match then redirect them to https:
#force https for certain pages
RewriteCond %{REQUEST_URI} !^/gapp
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
来源:https://stackoverflow.com/questions/25803626/how-to-route-a-particular-url-to-both-http-and-https-and-others-to-https-in-apac