How can I set 301 redirect to all URLs of Website?

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.blueseotools.com [NC]
RewriteRule ^(.*)$ https://blueseotools.com/$1 [L,R=301,NC]

I have set up it for the base URL which works fine now but URLs under it are still accessible with both www and non-www prefixes eg : (https://www.blueseotools.com/robots-txt-generator) and (https://blueseotools.com/robots-txt-generator)

The code you posted should work for all pages on the website. Most likely, you have other rules in the .htaccess file which come before it and take precedence due to the [L]. Try moving the three lines you posted to the very top of the file.

1 Like

thank you so much! fixed!

I was looking for a solution finally fixed