mallix
mallix

Reputation: 1429

htaccess https off condition

I have created the below condition:

DirectoryIndex index.php
RewriteEngine on

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(shop|delivery-checkout|delivery-order|delivery-offer|confirm-sms-code|show-delivery-product|auto-search-product|add-product|update-product|remove-product|destroy-cart|get-cart|cuisine|og-shop) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]

RewriteCond $1 !^(index\.php|robots\.txt|website|shop_files|shop_list|client|favicon\.ico|style\.css|sitemap.xml)
RewriteRule ^(.*)$ ./index.php?/$1 [L]

AddCharset utf-8 .js

What I am basically trying to do is check if (https) is not present in URL.
So except URLs referred, rewrite it to https://www.

Note: I am loading those urls: domain.com/shop, domain.com/delivery-checkout, domain.com/delivery-order inside an iframe and that is why I want those excluded and secure or not depending on parent site.

What am I doing wrong?

Upvotes: 1

Views: 5271

Answers (1)

anubhava
anubhava

Reputation: 785146

Change your code with this:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/(shop|delivery-checkout|delivery-order) [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

Upvotes: 1

Related Questions