After implementing ssl on wordpress, I wanted to force a redirection to a site with the following characteristics:
non www, ssl, with trailing slash
Unfortunately it only works in some cases.
For instance, instead of redirecting from a site with these characteristics (http, non www, without trailing slash to https, non www with trailing slash), it redirects like this:
http://example.com/foo
overhttps://example.com/foo
tohttps://example.com/foo/
.
I also have an issue with redirecting a www, http site without trailing slash to an https, non www, with trailing slash site.
Currently, it redirects from http://www.example.com/foo
via http://example.com/foo
to https://example.com/foo
and https://example.com/foo/
.
Therefore my question is: How can I fix this? Is this done somehow by the Wordpress system?
Enclosed you'll find my .htaccess
file. I hope you can help me.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
RewriteCond %{REQUEST_URI} !wp-content\/cache\/(all|wpfc-mobile-cache)
Could this be somehow caused by WordPress? I've mentioned this before, but there is also a rewrite code from WordPress.
# 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>
.htaccess
file you've posted (in two parts) is not complete and the order of directives is important. This order is not clear from what you've posted.