I want to make a rule in my .htaccess file, to redirect my www.example.com and www.example.com/index.html to example.com
Thanks
I want to make a rule in my .htaccess file, to redirect my www.example.com and www.example.com/index.html to example.com
Thanks
You can combine both requirement in a single rule like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{THE_REQUEST} /index\.html[?\s] [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^(.*?)(?:index\.html)?$ http://%1/$1 [L,R=301,NE,NC]
Create a .htaccess file. And add this:
#Force non-www:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.YOURDOMAIN\.com [NC]
RewriteRule ^(.*)$ http://YOURDOMAIN.com/$1 [L,R=301]
thiis should work seamlessly
RewriteCond %{HTTP_HOST} ^www\.sitename\.com [NC]
RewriteRule ^(.*)$ https://sitename.com/$1 [L,R=301,NC]