Redirect via .htaccess Issue

Hi, I am new to this forum, I hope someone can help me out.
I have an issue, I think (but not 100% sure) it is related to .htaccess.
The problem is: All my inner pages are redirection fine, but not the home page. I want to use the www version - so it would be: https://www.MyDomain.com. However, as it is now - I get a non-www and a www version of the homepage. It redirects correctly for all www and non-www version as HTTP, but not as HTTPS.

Here is my current .htaccess ( I have replaced the domain name with "MyDomain.com" and also removed some rules that are not related to this issue (I hope :-)).

BEGIN WpFastestCache

<ifmodule mod_rewrite.c="">
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www.MyDomain.com</ifmodule>

Start WPFC Exclude

End WPFC Exclude

Start_WPFC_Exclude_Admin_Cookie

RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^=]+=Ira

End_WPFC_Exclude_Admin_Cookie

RewriteCond %{HTTP_HOST} ^www.MyDomain.com
RewriteCond %{HTTP_USER_AGENT} !(facebookexternalhit|WhatsApp|Mediatoolkitbot)
RewriteCond %{HTTP_USER_AGENT} !(WP\sFastest\sCache\sPreload(\siPhone\sMobile)?\sBot) RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{REQUEST_URI} !(\/){2}$ RewriteCond %{QUERY_STRING} !.+ RewriteCond %{HTTP:Cookie} !comment_author_ RewriteCond %{HTTP:Cookie} !woocommerce_items_in_cart RewriteCond %{HTTP:Cookie} !safirmobilswitcher=mobil RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/all/$1/index.html -f [or] RewriteCond /srv/users/serverpilot/apps/MyDomain/public/wp-content/cache/all/$1/index.html -f RewriteRule ^(.) "/wp-content/cache/all/$1/index.html" [L]

<filesmatch "index\.(html|htm)$"=""> AddDefaultCharset UTF-8 <ifmodule mod_headers.c=""> FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Mon, 29 Oct 1923 20:30:00 GMT" </ifmodule> </filesmatch>

BEGIN rlrssslReallySimpleSSL rsssl_version[3.1.2]

<ifmodule mod_rewrite.c=""> RewriteEngine on RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{REQUEST_URI} !wp-content\/cache\/(all|wpfc-mobile-cache) RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/ RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L] </ifmodule>

END rlrssslReallySimpleSSL

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

1 Reply

You might want to consider dropping the www part. Chrome, one of the most popular browsers, is moving towards hiding the "www" in the address bar by default.

However, as this appears to be Wordpress you should make sure the URL in the wp-admin setting is set to https://www.domain.com

Also, you should consider not using .htaccess. Below is a link to two sites explaining why.

https://httpd.apache.org/docs/current/howto/htaccess.html#when

https://nystudio107.com/blog/stop-using-htaccess-files-no-really

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct