Issue with HTTP link not forwarding to HTTPS - wordpress

I have recently implemented the HTTPS/SSL on a website. I have impleted it correctly and everything works correctly accept 1 issue.
When I got to www.domain.com or doamin.com directly it doesnt go to the https://www.domain.com instead it just stays on the non https link. How can this be fixed?
My site is on Wordpress and using W3TC Page Cache plugin

In the .htaccess file in the root of your server, or in the Apache config add a rewrite rule to redirect HTTP to HTTPS:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Test the rules on http://htaccess.madewithlove.be/.

Related

Allow people to connect to my https website using http connection?

My website is currently https. But when attempting to browse it on a new computer, it always shows ERR_CONNECTION_REFUSED unless I turn it from http://mywebsite.com to https://mywebsite.com and then it's fine after that since it's saved to the browser.
How can I allow http connection to https website? I tried
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
But it's still the same.
Server: Apache2
on certbot, allow redirects so it will do the ReWrite code for you.

How to Redirect my all post/page in Http to Https

I am using wordpress. Actually recently I updated my website with SSL certificate in that everything is done. I have added redirect code in my .htaccess file.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
But only Homepage working perfect. It's automatically redirecting
http://www.lyricstake.com to https://www.lyricstake.com, but all other pages/post requests did not get redirecting. I want redirect my all post requests automatically, for example http://www.name.com/post/ to
https://www.name.com/post/.
You have to change all the URLs in your database from http to https. For doing this you can use this plugin : https://wordpress.org/plugins/search-and-replace/
Make sure to take a full backup of your database before using this plugin.

How can I redirect my 'http' URLs to my new 'https' URL (Redirect 301)?

I have installed an SSL Certificate on my hosting, for my wordpress site.
How can I redirect my old 'http' URL to my new 'https' URL, through the use of the .htaccess file, with minimum effect on my SEO Rankings?
The first option is to configure your website to work via HTTPS instead of HTTP. By default, WordPress is redirecting all of other links to the default protocol(in your case HTTPS).
You can configure it via WP-Cli. The command you need is:
wp search-replace 'OLD-URL' 'NEW-URL' --precise --recurse-objects --all-tables-with-prefix
You may check the following tutorial for more information:
https://developer.wordpress.org/cli/commands/search-replace/
Another option is to set the 301 redirects in the .htaccess. I am using the following code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Additional information on these types of moves from Google can be found at: https://support.google.com/webmasters/answer/6033049?hl=en&ref_topic=6033084

301 Redirect Not Working .htaccess

I have the following redirect code in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301,NC]
</IfModule>
# END WordPress
AddHandler php-stable .php
I'm trying to redirect all traffic from olddomain to newdomain. Not that the new domain does use "www".
When clicking on an old link elsewhere on the net that would refer to a post, redirect does seem to happen but it does not add in the correct slash after the domain name.
Here is what happens, the link to my old domain is as such on a website (just posted by someone):
http://olddomain.com/some-blog-post/
When I click on that link in a browser, it actually opens up:
http://www.newdomain.comsome-blog-post/
The slash between the domain and the blog post is missing.
Also, if it helps I'm using MediaTemple as my host for the old domain and I'm modifying my .htaccess file in
domains/olddomain.com/html/.htaccess
Anyone have any idea out there? Thanks a ton, I'm stuck.
Ok I just checked on this a little more and it turns out everything is working fine with the .htaccess code I pasted above.
My web browser was caching aggressively and I just had to dump the cache (or use private browsing).
See here for more debugging tips:
Tips for debugging .htaccess rewrite rules
maybe this is better:
RewriteCond %{HTTP_HOST} ^(.*\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://%1newdomain.com/$1 [R=301,L]
It matches both the subdomain and request URI and merges them with the new domain. If there is no subdomain, it proceeds to match the request and will redirect without a subdomain.

Installed Wordpress Network with www in the Site URL. How do I fix this?

I made a huge mistake. I set up a network without changing sitename to non-www, so now example.com (without www) is a non-existing page. How do I fix this? Changes in
settings
DNS
htaccess
?
I've tried htaccess redirect but wordpress sees the first request and still says www is missing.
We can't edit the Wordpress source code to redirect, as it will be broken on future updates. We can't forward all requests to the www-version of that request as that will break all subdomains.
I solved this with some edits to the root .htaccess file.
# This is probably how your file starts already
RewriteEngine On
RewriteBase /
# Then you add a condition: if the host starts with example.com
RewriteCond %{HTTP_HOST} ^example.com.*$
# And add a rule: redirect that url to the same url just with prepended with www
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Here the file continues with other stuff from WP
RewriteRule ^index\.php$ - [L]

Resources