I have a problem with my wordpress fresh installation. I'm using the .htaccess
to redirect all my traffic on https, but every time I see a 302 error page. How I can fix this?
here is the .htaccess
file code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
Options All -Indexes
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I have a problem with my wordpress fresh installation. I'm using the .htaccess
to redirect all my traffic on https, but every time I see a 302 error page. How I can fix this?
here is the .htaccess
file code
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
Options All -Indexes
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
First, you should not customize anything between # BEGIN WordPress and # END WordPress, it's just not a good practice. You should add your own rules above WP rules. And you should also make use of some flags, like "L".
# BEGIN Custom
<IfModule mod_rewrite.c>
Options All -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}/$1 [NC,R=301,L]
</IfModule>
# END Custom
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Also, instead of defining WP site URL through admin you should define it using constants in wp-config.php
. Here is a snippet you could make use of:
$protocol = ! empty( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
define( 'WP_HOME', $protocol . 'yoursite' );
define( 'WP_SITEURL', WP_HOME );
For more info: https://codex.wordpress/Changing_The_Site_URL
https
- this can be found in thewp_options
table. If your site is multisite, check the site'ssite_url
as well. – phatskat Commented Mar 1, 2019 at 19:11