.htaccess : domain change switch to HTTPS
-
Hey there !
Self hosted here, basic LAMP server.
I recently switched from a domain to another in addition to switching to HTTPS.For everything to be perfect, i’d need those redirections :
https://(www.)old.org/${anything} > https://www.new.org/${anything}
https://(www.)new.org/${anything} > https://www.new.org/${anything}Here is what i did in my .htaccess for now
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # Redirect mesnie.org to terageek.org RewriteCond %{HTTP_HOST} ^(?:www\.)mesnie\.org$ [NC] RewriteRule ^ https://terageek.org%{REQUEST_URI} [L,R=301] # Enforce HTTPS RewriteCond %{HTTPS} Off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
What works :
Now, the old domain switches right to the new keeping the right URL.
Visiting the new domain adds the www if needed.What doesn’t work :
The HTTP to HTTPS doesn’t work.
Going to https://old.org/${anything} switches to https://new.org/${anything} instead of https://www.new.org/${anything}, until of course visitors click a link.So, any idea on how to tweak my .htaccess ?
- The topic ‘.htaccess : domain change switch to HTTPS’ is closed to new replies.