Welcome to the Tidy Design News Blog
A blog for developers, marketing gurus, designers and clients... Articles and news on SEO, JavaScript, CSS, XHTML, PHP, Photoshop...

Archive for the ‘.htaccess’ Category

Redirect www.domain.com to domain.com using .htaccess

Sunday, June 26th, 2011

Just a quick blog post to share a cool little trick; how to redirect www.domain.com to domain.com using .htaccess

Ok, an Apache Web server supports URL rewriting with the mod_rewrite engine, so if you place various rules within a .htaccess file on your server, you can assist both search engines (who can usually figure out which format is preferred) and people who visit your site.

How to redirect www.domain.com to domain.com

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

And if you wanted to re-direct domain.com to www.domain.com then you would use

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Please note that both of these rules are search engine friendly, plus if you have pages within your site such as about.html or contact.php then the rule will also apply to them! There is also no right or wrong when it comes to domain.com or www.domain.com, it is personal preference!

We like to keep busy!

We have developed and licensed out a Hotel Booking System.

We created Montgomery Moon and setup the site Business Networking Link to help support start-ups.

To find out more about our other tidy adventures and business ideas please visit MJWARD UK

About Tidy Design

Based in Southsea, Portsmouth we are a small but highly motivated team of web design and SEO dudes who love what we do!

Our aim is to provide real value and inspiration to people looking to get on the web and grow their business.

Read more.

Blog Admin

© 2013 Tidy Design
Log in

 twitter icon