Gerald Ferreira Gerald Ferreira - 2 months ago 10x
PHP Question

htaccess wordpress https rewrite rule

I am hoping that you can help me with the htaccess rewrite rule below.

# BEGIN WordPress

# WPhtc: Begin Custom htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

I have recently changed my wordpress site from http to https... The problem is that old url's redirect to the domain name instead of the https version of that page


if I access the following page
it works 100%, now if I change the
part to
then the page redirects to
instead of to
how do I fix it so that if you go to the old version page
(the not https version) that it redirects to
instead of just the domain name


You have to find a workaround for %{REQUEST_FILENAME} since this only represents the file that is accessed. But you obviously want to access the SSL vHost. So you might hardcode the https into your .htaccess.

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

This might help you alot. (found the code above there)