Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1022535
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
Closed. This question is off-topic. It is not currently accepting answers.
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?
- why do you need to redirect https to http? – Vishwa Commented Apr 30, 2019 at 7:04
- @Vishwa because google is indexing both https and http – meysam Commented Apr 30, 2019 at 7:06
- 1 you dont need to add both to search console. google always prefer https over http. you dont need to add redirect to make google crawl your http version anyways – Vishwa Commented Apr 30, 2019 at 7:08
- 1 A verry good answer can be found here: webmasters.stackexchange/questions/68435/… – Roy van Wensen Commented Apr 30, 2019 at 11:58
-
3
I'm curious... if your site is accessible by both HTTP and HTTPS why were you choosing to favor HTTP over HTTPS? Does your site not work properly over HTTPS? I didn't downvote either, but I imagine this is because...
.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
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
本文标签: htaccessRedirect from https to http or from http to https
版权声明:本文标题:htaccess - Redirect from https to http or from http to https? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745479891a2152489.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
.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