Raphael Portmann Raphael Portmann - 1 month ago 5x
PHP Question

Forcing Non-SSL when specific url parameter is given

Ok I found out that I can force users to use SSL by changing something in the .htaccess file:

RewriteEngine On
RewriteBase /

# Force SSL
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Deny Access to all .htaccess
<Files .htaccess>
order allow,deny
deny from all

I'm not really good in writing .htaccess files so i most likely copy-paste it from the internet.

My question is if it's possible to always force ssl with one exception (When someone is visiting a http site with a specific url parameter).

Example 1:


gets redirected to


Example 2:


doesn't get redirected to


Is it possible to write that in htaccess or do i need to include a php file to every single page that's doing this?


This question is a DUPLICATE


Put this before the # Force SSL condition.

RewriteCond %{QUERY_STRING} (^|&)nossl=(1)(&|$)
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]