Acquia Drupal Website, Part 3

Internal Drupal Housekeeping

The basic Drupal core installation has two files included that influence how your pages are served and indexed. Both of these are in the root directory of Drupal’s installlation files.

Robots.txt

The robots text file settings allow you to set up rules for how your website’s pages are indexed. This can be done for various reason, including trying to avoid having your content showing up as duplicate content within your site. The basic settings are fine but I do like to add the following rules to my robots text file.

# Additional Rules
Disallow: /node$
Disallow: /user$
Disallow: /*sort=
Disallow: /search$
Disallow: /*/feed$
Disallow: /*/track$
# If you don’t want the bulk of your “recent posts” pages indexed, add this:
Disallow: /tracker?
Disallow: /*size=

To get this done I open up the robots.txt file that is in the root of my installed Drupal files (or the root of the files that are now on your hosting server). I paste in the text I have given above, adding it to the bottom of the page. The document is saved and copied to the host server, replacing the existing copy of the file.

.htaccees

Another file that I modify is .htaccess. It too is located in the root of the install file directory. The purpose of this file is to set controls for address (URL) assignments. The change I make here is to redirect any requests for non-www pages of my website to the www version of that page.

I opened the file in notepad and proceeded as follows:

Find the following section and uncomment the last two lines

# To redirect all users to access the site WITH the ‘www.’ prefix,
# (http://example.com/… will be redirected to http://www.example.com/…)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

changes to…

# To redirect all users to access the site WITH the ‘www.’ prefix,
# (http://example.com/… will be redirected to http://www.example.com/…)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

The last two lines are then modified to substitute my URL address for “example.” For my site the change is…

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

Once completed the file needs to be saved and copied to the root of your Drupal directory.

I can now type learnlocalhistory.com in the address bar of my browser and it will open up the homepage as www.learnlocalhistory.com

As an aside, both of these file changes could be made before the set of Drupal files are uploaded to your host server.