I need help about a configuration. I have an .htaccess for my frontend webserver which is so configured:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/?(dir_a|dir_b|dir_c)
RewriteCond %{QUERY_STRING} !^/?(dir_a|dir_b|dir_c)
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
DirectoryIndex index.php
So, dir_a, dir_b and dir_c, which are on the frontend server, are not redirected to https. Everything on the frontend server is correctly redirected to https if https is omitted or using http when one inputs an URL of my website. This does not happen for a location pointing to an internal webserver, ie I have in my apache2.conf:
<VirtualHost *:443>
...
ServerName example.com
SSLEngine on
SSLProxyEngine On
...
</VirtualHost>
...
<Location /backsrvdir>
SSLRequireSSL
ProxyPass http://192.168.x.y/backsrvdir
ProxyPassReverse http://192.168.x.y/backsrvdir
</Location>
In backsrvdir I have another .htaccess with its DirectoryIndex bsindex.php. It works only if the link already contains https:, so if I write or click on https://example.com/backsrvdir it's ok, if omit https: or using http: the frontend server responds with a "403 Forbidden: You don't have permission to access /backsrvdir/ on this server. Apache/2.2.22 (Debian) Server at example.com Port 80". As I stated above, port 80 is open only for dir_a dir_b and dir_c. Any idea to solve the problem and have http://example.com/backsrvdir redirected to https://example.com/backsrvdir ? Thanks in advance.
Try something like this:
<VirtualHost *:80>
...
Redirect permanent /backsrvdir https://example.com/backsrvdir
# Remove the other 3 lines:
# SSLRequireSSL
# ProxyPass http://192.168.x.y/backsrvdir
# ProxyPassReverse http://192.168.x.y/backsrvdir
...
</VirtualHost>
Also remove anything related to https redirection from .htaccess
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.