Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionWe have a WordPress blog, google is indexing http
as well as https
urls. Now we are considering to either redirect https
to http
, or to use https
and redirect all http
traffic there. And how can we make all necessary changes to our WordPress installation?
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionWe have a WordPress blog, google is indexing http
as well as https
urls. Now we are considering to either redirect https
to http
, or to use https
and redirect all http
traffic there. And how can we make all necessary changes to our WordPress installation?
2 Answers
Reset to default 2If available always use https
, it is securer for obvious reasons, it is better received by search engines and browsers nowadays, it is just overall preferable.
1 Backup
Should go without saying, but backup your database. There is always a possibility that something goes wrong. Additionally, make sure you have access – ssh, ftp, etc – to your files, and you have a possibility to access – ssh (mysql, wp-cli), phpmyadmin, etc – the database.
2 Set URL
Either under Dashboard > Settings > General:
Or use constants in wp-config.php
:
define( 'WP_HOME','https://example' );
define( 'WP_SITEURL','https://example' );
3 Update database
Either use the Search Replace DB tool:
- https://interconnectit/products/search-and-replace-for-wordpress-databases/
- https://github/interconnectit/Search-Replace-DB
Or make use the WP-CLI command search-replace
:
- https://developer.wordpress/cli/commands/search-replace/
Example: wp search-replace 'http://example.test' 'http://example'
Both above options have an option to dry run, test, before making changes.
Bonus, this plugin gets recommended a lot by people I generally trust:
- https://wordpress/plugins/better-search-replace/
Note: I personally have no experience with the plugin; I'm adding it for completeness’ sake.
4 Enforce redirecting to https
Either via adding the following lines to the .htaccess
:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Or you can generally set this via your server administration gui, so plesk, cpanel, webmin or whatever your hosting provider is offering.
You can paste this code in the wp-config.php file to define your new URL.
define('WP_HOME','http://yoursite'); //Enter your new URL
define('WP_SITEURL','http://yoursite'); //Enter your new URL
.htaccess
specific questions are generally off-topic on WordPress SE (these are better suited to the Webmasters Stack). You don't give any specifics as to what "doesn't work"? Errors? Incorrect redirect? Nothing? And... in 2019 there should be no need to redirect HTTPS to HTTP - so what you are suggesting is against all recommendations. – MrWhite Commented Apr 30, 2019 at 17:50