Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to redirect any URL that is Https and hasn't start with "system_" to the same URL with http.

for exapmle for this url :

https://exsite.tld/some/thing/that/not/start/with/pattern

to :

http://exsite.tld/some/thing/that/not/start/with/pattern

but this url:

https://exsite.tld/system_aas3f4

Shouldn't redirect.

I try:

  RedirectMatch  ^/?((?!(system_)).*)  http://exsite.tld/$1

but it won't work. I don't know what's the problem.

share|improve this question

1 Answer 1

up vote 4 down vote accepted
+50

Use rewrite instead. Try something like

RewriteEngine on
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/system_
RewriteRule ^/(.*) http://exsite.tld/$1 [R=301,L]

ought to do it. Please test it before implementing in live environment.

What these rules state is: 1. enable rewrite engine, 2. check if HTTPS is on, 3. check if the URI path does not start with system_. If both the above two conditions are true, do the rewrite to http version of your domain for all remaining URIs.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.