Qiang Zhao
Qiang Zhao

Reputation: 11

301 redirect in bitnami wordpress

301 redirect http://example.com -> https://www.example.com

301 redirect https://example.com -> https://www.example.com

301 redirect http://www.example.com -> https://www.example.com

I know how to do this in .htaccess ,but it does not work in bitnami wordpress . help!

this is my config in /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf .

Picture here

Upvotes: 1

Views: 2022

Answers (2)

Marian
Marian

Reputation: 1

The problem is because wordpress trying to protect your website against chained redirects. When it is checking if is ssl there exist a case which is missing. I fixed this problem by opening wp-config.php and replacing the code:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

with :

if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
    $_SERVER['HTTPS'] = 'on';
}
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/');
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/');

Hope to help you too.

Upvotes: 0

Juan Ariza
Juan Ariza

Reputation: 1058

As you can see in the documentation: https://docs.bitnami.com/google/components/apache/#how-to-configure-htaccess-files

All the .htaccess files are collected into a single one file in the Bitnami WordPress Stack. You can find it at /opt/bitnami/apps/wordpres/conf/htaccess.conf. Therefore, you can edit that file an add your own rules in order to modify that configuration. You can also edit the file /opt/bitnami/apps/wordpres/conf/httpd-app.conf which contains other Apache rules and redirections.

Upvotes: 2

Related Questions