I want to redirect all my internal pages (eg: example.com/about
) to their non-www version but I want my homepage (https://example.com
) to redirect to its www version (https://www.example.com
).
I searched many articles on the internet but it could not work.
If set both rules then the internal pages get redirected fine but the homepage gets trapped in a loop.
I don't know how to code so please it's a request if you could write the code which I should paste in my .htaccess
file
Currently, I have set all pages to redirect to their non-www versions (even homepage) with the below code:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301]
</IfModule>
# BEGIN Sitepad
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END Sitepad