我正在努力与反向代理configuration和具体的重写/ proxypass取决于URLpath。
SZENARIO:
我目前的configuration:
<VirtualHost *:80> ServerName media.customer.com RewriteEngine On RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$ RewriteRule ^(.*)$ https://media.customer.com$1 [R=301,L] </VirtualHost> <VirtualHost *:443> ServerName media.customer.com DocumentRoot /var/www/customer.com/ SSLEngine On SSLCertificateKeyFile /etc/apache2/certs/server.key SSLCertificateFile /etc/apache2/certs/server.crt ProxyRequests Off ProxyPass / http://serverName/ ProxyPassReverse / http://serverName/ ProxyHTMLEnable On ProxyHTMLURLMap http://serverName/ / </VirtualHost>
这不会是一个大问题,但我们需要得到以下规则工作:
上面的configuration适用于:
我把“/ fotoweb /”放在RewriteRule或ProxyPass中,我们得到了两倍的string: http://serverName/system/system/img/test.gif
对于我的意见,我需要确定它的基地址,然后添加“/系统/”,否则只是映射到http。 但不知道如何做到这一点。
提前致谢!
这将所有不是HTTPS的内容重写为HTTPS:
RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
不知道你认为“base-url”,但我假设它是HTTPS +不是以'/ system'开头。 这会将所有不以'/ system'开始的内容重写为'/ system / …':
RewriteCond %{REQUEST_URI} ! ^/system RewriteRule .* /system%{REQUEST_URI} [R=301,L]
如果只是“/”,那么:
RewriteCond %{REQUEST_URI} ^/$ RewriteRule .* /system/ [R=301,L]
一体:
<VirtualHost *:80> ServerName media.customer.com RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] </VirtualHost> <VirtualHost *:443> ServerName media.customer.com RewriteEngine on RewriteCond %{REQUEST_URI} ! ^/system RewriteRule .* /system%{REQUEST_URI} [R=301,L] DocumentRoot /var/www/customer.com/ SSLEngine On SSLCertificateKeyFile /etc/apache2/certs/server.key SSLCertificateFile /etc/apache2/certs/server.crt ProxyRequests Off ProxyPass / http://serverName/ ProxyPassReverse / http://serverName/ ProxyHTMLEnable On ProxyHTMLURLMap http://serverName/ / </VirtualHost>