Server side issues for a website on a shared hosting, the answers

Some questions about how to manage a site on the server (with a shared hosting).

To execute PHP 5

Put the following command in .haccess under Apache:

SetEnv PHP_VER 5
On other UNIX servers that can be:
AddType x-mapp-php5 .php

Consult the instructions of your provider to make sure that the environment variable used is the same.

Change the extension file that the server must parse for embedded PHP code

If we put PHP code in a page with the .html extension, how to make the server processing the PHP code? By placing a command as in the next .htaccess:

AddType application/x-httpd-php .htm .html

.htm and .html are examples. The command will do that files with these extensions are handled by the server as the files with the .php extension.

Protect a directory by a password

By modifying the file .htaccess. This can be done most simply by using a tool that will automatically generate the file.

Block aspirators

You can insert the following code in your.htaccess file.

Prevent a spam site to link my site

In the .htaccess file, add the following lines:

SetEnvIfNoCase Referer ".*(domain | anotherdomain | etc. ).*" spammer=yes      
Order allow, deny 
allow from all 
deny from env=spammer

The names of the sites, domains with extensions, are placed in a list in parentheses and separated by the vertical bar.
This code combines a code to a range of domains, and the following lines give permission to all sites except the sites designated by the code of sending visitors. For the latter access is denied.

Relative or absolute URL to pages of the site

The URL of an internal link may take three forms:

The absolute path must be preferred. It refers to your site when the page is displayed on a news aggregator.
The relative path works only if the server is configured to set "/" as the root of the site (rather than the root account on the server). It is useful only to change the domain, an unlikely action.
Local paths must be avoided. Local URL are not taken into account by Analytics for statistical distribution of clicks.

Should I add / at end of URLs?

We can write a URL as:

http://www.example.com/forum or
In general, if it is a directory the server redirects the first on the second. But the first can be a file, it is often the case with Wordpress.
This is not a problem for Google, when there are two different links it indexes the file and the directory. When the server redirects the URL without a trailing slash on a directory, there is no duplicate content but for the crawlers of search engines is a complication to avoid.
Therefore in the case of a directory always add the slash. More infos on To slash or not to slash by Google Webmaster Central.

Separating words: a dash or an underscore

It has been announced by Google that an underscore is recognized as a separator in filenames or anchors.
Until now underscore character "_" did not separate words for search engines, so my_site is seen as one word, while my-site contains two words for engines. Using a dash as separator is still recommended.

Bilingual site

For a bilingual website, do we create different domains or subdomains or subdirectories for each language? These three solutions are suitable for different situations.

Subdomains: In this case, the less relevant is the use of subdomains. Indeed, they are seen by search engines such as different sites, then division of the PageRank. Better a site bigger than two small sites.
In fact we should use subdomains only for multiple users, each with access to own Webspace.

Country domains: Using different domains has the same drawbacks but with the advantage of the extension in relation to the language and URL clearer to the public.
The extension on language like .fr for example, gives an advantage for positioning on local search.

Subdirectories: However, having a larger site may outweigh the benefits of geolocation.
If traffic on the site is not large enough to justify multiple domain names, sub-directories are preferable.
Using a script to adapt the language to the user is in my experience, effective with the precautions listed in the article.

Best size for a web page

According to the study published by the site Websiteoptimization, in 2008 the average size of pages was 312 ko.
The recommended size would range 1000 to 20000 characters, and it is often the standard for professionals. Robots give more importance to the first part of the pages and this is a reason to shorten them.
Visitors prefer short pages when they surf for fun, but developed pages to document on a issue, in this case they are more prone to get backlinks.
What is important also is the dowload time, to know it you have tools such as Google's Webmaster Tools.

Favicon: a picture in front of my site in the URL bar

This favicon also appears in the bookmark panel.
It's a kind of icon from Windows, named favicon.ico, with a size of 16x16 pixels or 32x32 pixels, which must be placed in the root directory.

See also:

Redirects on a website. Using the .htaccess file.