apache - Redirect to SSL except when URL matches a certain criteria -


this htaccess code:

rewriteoptions inherit rewriteengine on  rewritecond %{server_port} 80  rewriterule ^(.*)$ https://www.domain.com/$1 [r=301,l]   adddefaultcharset utf-8 rewritecond %{http:authorization} ^(.*) rewriterule ^(.*) - [e=http_cgi_authorization:%1]  rewritecond %{request_filename} !-f rewriterule    ^([0-9a-za-z]{12})(\/.+|\.html?|$)   /cgi-bin/index_dl.cgi?op=download1&id=$1&fname=$2 [l] rewriterule    ^ot:(.*)             /cgi-bin/index_dl.cgi?op=download1&otid=$1 [l,b] 

currently redirecting ssl. want when filename fulfills criteria

rewriterule    ^([0-9a-za-z]{12})(\/.+|\.html?|$)   /cgi-bin/index_dl.cgi?op=download1&id=$1&fname=$2 [l] 

it needs allow non-ssl

i've googled , googled can't figure out how this.

any appreciated :)

in rule redirect, add exclusion condition:

rewritecond %{https} off rewritecond %{request_uri} !^/([0-9a-za-z]{12})(\/.+|\.html?|$) rewriterule ^(.*)$ https://www.domain.com/$1 [r=301,l] 

or can combine rule's pattern:

rewritecond %{https} off rewriterule !^([0-9a-za-z]{12})(\/.+|\.html?|$) https://www.domain.com%{request_uri} [r=301,l] 

edit:

to redirect ssl requests pattern non ssl add right below other redirect rule:

rewritecond %{https} on rewriterule ^([0-9a-za-z]{12})(\/.+|\.html?|$) https://www.domain.com%{request_uri} [r=301,l] 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -