One important factor when dealing with SEO is how Google interprets your website in its indexes.
When you register a website you will have something like:
http://www.domain.com (.co.uk etc)
However when Google indexes your website it will see:
http://www.domain.com (.co.uk etc)
AND
http://domain.com (.co.uk etc)
Google will class this as 2 separate websites to index, thus will affect SEO ranking since it assumes its duplicate content....
A simple text editor such as Note Pad
The first approach uses a special file called the .htaccess (notice, there is a 'period' in front of htaccess suggesting that this is the file extension and thus no filename).
This file corrosponds to LINUX based systems only.
This approach is for anyone who has access to uploading to a hosting server for their website and the ability to upload a .HTACCESS file.
Copy this code into your chosen text editor and change the "yourwebsite" reference to what ever website URL you are referencing.
# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yourwebsite\.co.uk
RewriteRule (.*) http://www.yourwebsite.co.uk/$1 [R=301,L]
Ok so you have the code in place in your chosen text editor, you canot simple save it as you usually would as this would then prefix the extension .txt to the file your saving (so it ends up being .htaccess.txt) ...That would then make the file unoperational for the Linux server.
What you need to do is make sure SAVE AS is selected and then select ALL FILES then simple type in .htaccess (remember the period in front of the htaccess).
ok so you sucessfully saved the file your now ready to upload it to the websites hosting server...whats important here is that in your chosen FTP software that you select ASCII as the uploading type for this file....very important!
You should be uploading this file to the root directory of your website...the way it works is that you could potentially have a different .htaccess file in different directories on your website hosting server which can perform so many different things...but for "sitewide" operation you would need to make sure its uploaded to the root for your website.
I use SmartFTP for uploading to my hosting servers and here is a screenshot of where to select ASCII for the uploading of the .HTACCESS file.
This was kindly sent to me by WebAssist one and only Ray Borduin. And its a different approach in case you dont have direct access to uploading files or have access to uploading a .htaccess file (perhaps your hosting provider prevents that type of file from being uploaded).
Add this code to the top of everypage...or copy it to a new page save it using the .php file extension and then use a php include to include it to what ever pages you want...or if required for site wide integration then add this code to your dreamweaver template or WebAssist Framwork Builder template.
//make sure www is in the url
if(strpos($_SERVER['SERVER_NAME'], 'www.') === false) {
$redirect = ((!empty($_SERVER['HTTPS'])) ? 'https://' : 'http://') . 'www.' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header('Location: ' . $redirect);
}
Add this code to the top of everypage...or copy it to a new page save it using the .php file extension and then use a php include to include it to what ever pages you want...or if required for site wide integration then add this code to your dreamweaver template or WebAssist Framwork Builder template.
//remove www from the url and redirect only if www is in the url
if(strpos($_SERVER['SERVER_NAME'], 'www.') === 0) {
$redirect = (!empty($_SERVER['HTTPS']) ? 'https://' : 'http://') . substr($_SERVER['SERVER_NAME'],4) . $_SERVER['REQUEST_URI'];
header('Location: ' . $redirect);
die();
}
Name other uses for the .HTACCESS file ...
What else can it allow the developer to do on a website??
Comments will be sent to the author of this tutorial and may not be answered immediately. For general help from WebAssist, please visit technical support.
Sign in to add commentsYour friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.
Jamie: 11 Years, 7 Months, 2 Days, 4 Hours, 17 Minutes ago
I also use the .htaccess file to restrict access to accidental visits to the uploaded files folder... you just create another .htaccess file and in it all you have to do is put Options -Indexes and then upload that to the folder you wish to restrict accidental access to.
It still allows the site to reference images/files that have been uploaded as well as allowing the site owner to access the file manager.