Can't access website admin panel , https to http migration misconfiguration - .htaccess

Website Backend: codeigniter php
So I was trying to change http to https to my website, My college has a SSL certificate in our college domain in which http was working fine, I added these 3 line to my main .htaccess file
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
So basically what is doing is redirecting to https whenever a request is made to http, Since I haven't configured my https properly, It is showing
This page cant be reached
When I was trying change back my .htaccess file I couldnt even open admin panel because the admin panel is in the same domain , so it is again showing the error.
Anyone help me please
Thanks in advance

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domainname\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domainname.com/$1 [R=301,L]
try this way

Related

.htaccess specific code to redirect http traffic to https and redirect subdomain traffic to offsite domain

I have recently set up a site "saskatoonwashworld.com" with SSL. I have two issues that I need to resolve...
1) Route all http requests to https (I was able to do this easy enough with code found online)
2) I also have a subdomain "portal.saskatoonwashworld.com" which I want redirected to "https://secure3.washcard.com/AP?CID=65e53149-59e9-4d67-a746-e475aa4bc7be" which is hosted by another site. I want the requests to go here whether or not the user types in http://portal.###, https://portal.###, or just the url without the http(s).
I cannot figure out how to do it as I don't know how to properly code the conditions and rewrites.
I was originally using this code found online for the http to https redirect...but if I'm understanding it correctly, it is using a wildcard to catch "www." and so would ignore/override my "portal." subdomain anyways. But I could be wrong.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://saskatoonwashworld.com/$1 [R=301,L]
Try this rewrites in .htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?portal\.saskatoonwashworld\.com [NC]
RewriteRule (.*) https://secure3.washcard.com/AP?CID=65e53149-59e9-4d67-a746-e475aa4bc7be [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://saskatoonwashworld.com/$1 [L,R=301]

How do I correct "This webpage has a redirect loop" error when redirecting to HTTPS?

I have a domain/DNS registered with A and the site itself on B, a cloud sites provider. On B I have the SSL cert installed. Both the http and https URL work when used. I want to redirect all http traffic to https. So I made a .htaccess file:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomainhere.com/$1 [R,L]
It redirects to the https site in the URL but doesn't load the site. The error says "This webpage has a redirect loop ERR_TOO_MANY_REDIRECTS." Is this because the route is going to A which is told to go to B? If so what is the solution? If not, what am I doing wrong here?
Thanks in advance for your help!
Ahh figured it out!
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.mydomainhere.com/$1 [R,L]

https to http redirect not working godaddy shared hosting

I do not have any ssl certificate. So I am trying to redirect the domain with https to http using .htacces. But it is not working. Instead domain with https is showing godaddy's default coming soon page.
If you use apache, you can enter the following in a .htaccess file or in your apache configuration:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

URL rewrite stopped working with https URL

I am developing a PHP based website. I made it live with HTTP URL and URL rewriting.
let suppose my domain is www.abc.com
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$
RewriteRule ^([^/]*)/([^/]*)$ index.php?%{QUERY_STRING}&current_event=$1 [L]
And I access my site as http://www.abc.com/article it works fine.
Now my client installed SSL certificates on server and I want to change URL to HTTPS but accessing https://www.abc.com/article gives me 404 error.
Please guide me how can I make my above rules work with HTTP/HTTPS both.

Apache redirect all https (443) request to external server

I want to redirect all https requests (443) to another server, how can I do this in apache?
What I want to do is:
All https requests on https://server1.com redirect to https://server2.com
Anyone knows how I can achieve this? An example would be nice.
Thanks!
I would say something like this :
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^server1.ca$
RewriteRule (.*) https://server2.com/$1 [QSA,L]
If HTTPS, redirect everything to your new site coming from server1.com
You will need certificates in both servers, then you can redirect using .htaccess (if you're using apache) or web.config (if you're using IIS).
Example of .htaccess:
RewriteCond %{HTTPS} = on [NC]
RewriteCond %{HTTP_HOST} !^server2.com$ [NC]
RewriteRule ^(.*)$ https://server2.com/$1 [L]
If you're using IIS let me know, i can get you a sample web.config :)

Resources