I am trying to redirect my subpage to a non-www but I get duplicate URLs of the same page.
What I want to implement
https://www.example.com/category/webs => https://example.com/category/webs
http://example.com/category/webs => https://example.com/category/webs
http://www.example.com/category/webs => https://example.com/category/webs
.htaccess
Options -Indexes
RewriteEngine On
RewriteRule ^category/([a-zA-Z0-9-/]+) category-list.php?id=$1 [NC,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^example.com$
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>
With this current code, my root domain redirects perfectly. but not subpages! I read many articles but not helping