January 31, 2016

htaccess if site open with www and its redirect without www


- If you want to open your site with out www then just simple write 2 lines in you .htaccess file and upload it in your root server.

For example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.domainname.com [NC]

RewriteRule ^(.*)$ http://domainname.com/$1 [L,R=301]

Note: In above example replace your currect domainname. If you have SSL certificate then used https:// instead of http://.


- And if you want used force www on without www domain name,

- Then just below 2 lines in your .htaccess file and upload in your root server.

For example:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domainname.com [NC]

RewriteRule ^(.*)$ http://www.domainname.com/$1 [L,R=301,NC]

Note: In above example replace your currect domainname. If you have SSL certificate then used https:// instead of http://.

If you have any question related any .htaccess rules issue then please comment me here I will you to solved that.

Enjoy!

1 comment:

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...