If you want to redirect from URL without www (example.com
) to URL with www (www.example.com
) then this can be done easy be adding following rules to .htaccess
:
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Benefits
- Include HTTP and HTTPS protocol.
- Makes all URL-s consistent.
- Prevent from duplicate content that search engines will not collect same data more that once.
Leave a Reply