I want to exclude:
http://domain.com/index.php?route=payment/redsys/callback
This is what I have in .htacess
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
that convert all url to https, how can I exclude the url to be converted to https?
thanks
Try using this, just replace directory with the folder directory that you want to stop beocming HTTPs.
RewriteEngine On
#Turns HTTPs on for everything, excluding directory
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^\/directory\/
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
#Turns HTTP on for directory
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} \/directory\/
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
Related
I have an .htaccess file see below
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
#Every www request to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
#every http request in amdinistrator folder redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/administrator
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
#every https request except ftp and one specific request redirect to http
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} !^/ftp
RewriteCond %{REQUEST_URI} !=/preview/index.php?request_type=preview_engime
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [L,R=301]
#redirect which request contains PUBLIC_AJAX_ENGIME
RewriteRule ^(.*)PUBLIC_AJAX_ENGIME(.*)$ index.php?request_type=ajax_engime [L]
#files and directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
</IfModule>
I do not want redirection in this case:
https://somewebsite.domain/preview/index.php?request_type=preview_engime
but the system redirects here
http://somewebsite.domain/index.php?request_type=preview_engime
and I do not understand why.
Thank you!
FF
This is because your url contains a querystring. You cant match against QueryString using REQUEST_URI variable. You need to match against THE_REQUEST variable. Replace your RewriteCond with this :
RewriteCond %{THE_REQUEST} !/index\.php\?request_type=preview_engime [NC]
I have a Rule in My base folder .htaccess file. The rule will automatically redirect http:// to https://. But for a specific folder or URL I need to access through http://
RewriteRule ^(.*)$ https:/%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
For example My website will be like https://<>/power/a/1
But I need to access some URL without https://
expected http://localhost/admin/rest_api/api_methods/
You need to implement an "exception rule" in form of a condition for the RewriteRule:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/webservices/access
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
# Turn SSL on for /user/login
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/admin/rest_api
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Turn SSL off everything but /user/login
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/admin/rest_api
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
This should work:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/webservices/access
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
It will redirect everything but the /webservices/access folder (or any other links in that folder like /webservices/access/login.php) to https
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?
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]
I have an old url (test.me.com) and I would like to redirect it to www.me.com.
So I added this line to my .htaccess file:
RewriteRule ^(.*)$ http://www\.me\.com/$1 [L,R=301]
But as it turns out, Google has already indexed some of the pages. And since I have an SSL Certificate, the full url is https://test.me.com. So the redirect of above won't affect the https files...
I've tried this one, but with no luck.
RewriteCond %{HTTPS} =on
RewriteRule ^(.+)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.+)$ - [env=ps:http]
# redirect urls with index.html to folder
RewriteCond %{HTTP_HOST} ^test.me.com [NC]
RewriteRule ^.*$ %{ENV:ps}://www.me.com/%1 [R=302,L]
How can I configure my .htaccess file that both http://test.me.com and https://www.test.com are redirected to http://www.me.com?
# redirect https requests or request on test.me.com to http://www.me.com
RewriteCond %{HTTPS} =on [OR]
RewriteCond %{HTTP_HOST} ^test\.me\.com$ [NC]
RewriteRule ^(.*)$ http://www.me.com/$1 [R=301,L]
or alternatively to also redirect me.com to www.me.com
RewriteCond %{HTTPS} =on [OR]
RewriteCond %{HTTP_HOST} !^www\.me\.com$ [NC]
RewriteRule ^(.*)$ http://www.me.com/$1 [R=301,L]
I would like to have the folder https_folder (including all subfolders and files) forcing https, but every other directory or file, utilizing http.
Folder structure:
foldera
folderb
https_folder
folderc
I tried to set it as followed, however i dont seem to get it working
redirect for http /https_folder
RewriteCond %{SERVER_PORT} = 80
RewriteRule ^https_folder/?$ https://%{HTTP_HOST}%/httpd_folder [R=301,QSA,L,NE]
redirect for https non /market pages
RewriteCond %{SERVER_PORT} =443
RewriteCond %{REQUEST_URI} !^/https_folder [NC]
RewriteRule ^/?(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
Any help would be appreciated
Do this:
RewriteCond %{REQUEST_URI} /https_folder/? [NC]
RewriteCond %{HTTPS} off
RewriteRule ^(https_folder)(/.*)?$ https://%{HTTP_HOST}/$1$2 [R=301,L,NE]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !/https_folder/? [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L,NE]
Put this code in your .htaccess file:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
# redirect to https if URI has https_folder
RewriteCond %{HTTPS} off
RewriteRule ^https_folder/? https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC]
# redirect to https if URI doesn't have https_folder
RewriteCond %{HTTPS} on
RewriteRule ^(?!https_folder/?)(.*)$ http://%{HTTP_HOST}/$1 [R=301,L,NC]