Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Redirect some requests from HTTPS to HTTP |
|
Author |
|
jimski
Joined: 18 Jan 2014 Posts: 196 Location: USSA
|
Posted: Sun 04 Sep '16 2:16 Post subject: Redirect some requests from HTTPS to HTTP |
|
|
I'm trying to setup Apache to redirect all HTTPS requests that don't contain word "payment" to HTTP.
For example https://website.com/payment-paypal.php should be redirected to http://website.com/payment-paypal.php
I tried this but it doesn't work. Probably my look-ahead rule is defective.
<VirtualHost _default_:443>
ServerName website.com
DocumentRoot "c:/server/www"
RedirectMatch ^(?!payment$)$ http://www.website.com/$1
SSL Directives Here .....
</VirtualHost>
When I specify each URL individually like below then everything works great.
<VirtualHost *:443>
ServerName website.com
DocumentRoot "c:/server/www"
RedirectMatch permanent "/questions(.*)" http://www.website.com/questions$1
RedirectMatch permanent "/policy(.*)" http://www.website.com/policy$1
.............
SSL Directives Here .....
</VirtualHost>
But I would like to use one regex rule because there are over 100 scripts that need to be redirected to HTP. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Wed 07 Sep '16 16:25 Post subject: |
|
|
I haven't tried, but in theory
Code: |
<Location />
<If ! "%{REQUEST_URI} =~ /payment/">
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
</If>
</Location>
|
|
|
Back to top |
|
|
|
|
|
|