I am trying to redirect my site from www to https. I have this code in htaccess file: [closed] - http

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
Improve this question
I have this website https://gss2023.iisdindia.in/ which is already redirected from http to https.
However when we try to access the same website with www prefix - it doesn't redirect to https and show error.
I already tried all the options available to update the .htaccess file but nothing seems to be working for this website.
Can you suggest changes in the .htaccess file ?
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?gss2023.iisdindia\.in
RewriteRule ^(.*)$ https://www.gss2023.iisdindia.in/$1 [R,L]

If the cause is a missing redirect from non-SSL to SSL, you'd use this in your .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L]
But as you're saying that it is already redirecting, I suspect the "error" you mention is that the www subdomain is missing from the certificate so that only the non-www spelling has SSL and when you try to open the www-spelling of the domain you get a browser "insecure page" SSL error. For that case it is not an issue with your redirect, but with a missing www subdomain in your certificate. Make sure that your SSL certificate includes both, the www and non-www spelling of the domain name.

Related

www redirect to non-www is not working despite everything I tried

I'm trying to redirect all versions of my domain to use https:// non-www version. I've tried many codes on this forum and answers to other similar questions. I use WordPress and DirectAdmin and tried the following:
Installed a couple of redirection plugins and set the default url to https://non-www
Created Regex rules
Added a bunch of codes at the begining of the .htaccess file found online (like the following)
Used page rules on CloudFlare
Nothing seems to be working.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^salamtavalod.ir$
RewriteRule ^(.*)$ https://salamtavalod.ir/$1 [R=301,L]

Why I can't redirect subdomain from htaccess while having Cloudflare?

Why I can't redirect subdomain from htaccess while using CloudFlare SSL?
PS I don't know if I can paste URL here so I won't paste it to avoid removal of the question.
I'm getting this problem in Chrome (but it doesn't work in Firefox either)
error
I know there are fixes on the internet for this error but none worked for me. Is it because I have root domain connected to CloudFlare (also affects subdomains)?
What I did is:
1. created a subdomain in hosting and set its file directory.
2. in that file directory made .htaccess file.
3. inside the file
Redirect 301 / https://rootdomain/firstfolder
but it falls into redirects loop :(
With my .htaccess code, I check if the domain has the www. dub on the domain, then I redirect it to the subdomain without the www. dub on it. Also, because I don't think you want to change it, I place a 301 Redirect on it also.
I forgot to mention, usually people do not use the www. on the subdomain also, so I am guessing that you don't want people to use it either.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^/?$ "http\:\/\/sundomain\.domain\.com\/" [R=301,L]
For specific url : put below code in your subdomain.domain.com's .htacess
Redirect 301 /blue-car/ http://www.example.com/cars/red-car

Redirect Incoming HTTPS Url to My Site's HTTPS Version

My client has a site http://www.sitename.com and also has a secure https://www.sitename version. For Google Analytics traffic reasons, he needs to make sure that any users coming from an https url be redirected to the secure version and NOT the insecure url.
What would be the proper way to do this via .htaccess? I searched here and online in general couldn't find a specific answer.
You will have to force https for achieving your use case. Add this to your htaccess file.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Cancelled SSL, Google still takes user to HTTPS

My problem is on a GoDaddy hosted Wordpress installation. I decided to move the site just a few days after adding SSL, and I left the certificate behind, I no longer want it. Many users are still seeing my site as https://example.com because Google indexed this, or because the site is in their cache. This is a big problem, because browsers throw up untrusted certificate warnings, and users don't continue on to the site.
I've been trying to solve this problem by:
Using Google Webmaster Tools and asking Google to re-crawl/re-index my URLs.
Trying to write a 301 redirect into my htaccess file, which would redirect from https to http.
My 301 redirects have not worked yet. I have read several articles and tried these code snippets:
RewriteCond %{SERVER_PORT} ^443$
RewriteRule (.*) http://example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}
I'm beginning to doubt that this will work. Does anyone know if it is possible?
In the end, only time healed this wound. Fortunately Google un-indexed my HTTPS address pretty quickly.

Do I need http instead of https on one domain in a multisite setup? [duplicate]

This question already has answers here:
Https to http redirect using htaccess
(7 answers)
Closed 9 years ago.
It seems that Vimeo doesn't work with https. We have a WordPress multisite on an hhtps where one of the sites has iframed Vimeo videos. There are links from other sites to the site with the videos. So, if someone links back to the site with Vimeo, the videos don't work.
I believe I need a redirect that will switch https to http on all addresses in that domain specifically, but not to the other domain/addresses. All the .htaccess code I have seen is for specific files, not for a specific domain. Or, is there another way to work around the Vimeo problem?
put this before # BEGIN WordPress in htaccess as seen here
and after modifying it a bit, you should get what you want.
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^domain-with-vimeo\.com
RewriteRule (.*) http://domain-with-vimeo.com/$1 [R=301,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
#wordpress multisite rules here
</IfModule>
# END WordPress

Resources