Setting Up Clean URL’s for Drupal With .htaccess

Posted by Dev Team August 17th, 2008

By default, Drupal passes path arguments to itself via its dynamically generated URLs. This results in URLs that look like “http://www.example.com/?q=node/83.” This can make URLs hard to read and it prevents some search engines from indexing the pages with these URLs. Research suggests this may not be as great an issue for some of the major search engines as it once was, however it is worth noting the recommendation from Google’s webmaster guidelines stating:

If you decide to use dynamic pages (i.e., the URL contains a “?” character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few.

You can tell Drupal to use “clean URLs”, eliminating the “?q=” in internal URLs. Note that this works only for Apache servers which have the mod_rewrite Apache module configured and mod_rewrite enabled in httpd.conf configuration file.

Sometimes when you’re setting up a new install of Drupal CMS, if you want Clean URL’s enabled, you might encounter a situation where the installer (or configuration manager) says your server is not setup to handle Clean URL’s. If you don’t have access to Apache’s httpd.con configuration file (as in shared hosting scenarios), you can easily use .htaccess to fix this issue.

All you have to so is create an .htaccess file in your install’s root directory with the following directives

#
# Apache/PHP/Drupal settings:
## Protect files and directories from prying eyes.

Order allow,deny
# Don’t show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.

ErrorDocument 404 “The requested file favicon.ico was not found.

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 5, Apache 1 and 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# Requires mod_expires to be enabled.

# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

# Do not cache dynamically generated pages.
ExpiresByType text/html A1
# Various rewrite rules.

RewriteEngine on

# If your site can be accessed both with and without the ‘www.’ prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the ‘www.’ prefix. Choose ONLY one option:
#
# 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]
#
# To redirect all users to access the site WITHOUT the ‘www.’ prefix,
# (http://www.example.com/… will be redirected to http://example.com/…)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

# Rewrite URLs of the form ‘x’ to the form ‘index.php?q=x’.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# $Id: .htaccess,v 1.93 2008/06/28 19:48:21 dries Exp $

That’s all there is to it !!

Tags: , ,

Building Forum Communities - Software is the Foundation

Posted by Dev Team February 25th, 2008

When developing a forum based community, the most critical aspect is choosing “which forum software to use?” At Resdaz, our forum software of choice for over two years has been Simple Machines (SMF) because it is “open source” and the foundational code can be altered to any extent by outside developers.

The only requirement for using the SMF forum software is that you must retain a hyperlink to the official SMF site at the bottom of every forum you operate using the software. All costs considered, it’s a small price to pay when you have the option of purchasing the leading competitor forum software, vBulletin (VB).

vBulletin is undeniably the most widely used forum software but vBulletin isn’t free nor is it “open source”. The operational cost is minimal, $85 per year for a “leased vBulletin Forum license”. If you’re operating only one forum, $85 per year for the license isn’t a lot of money to shell out especially if you have no intentions of modifying the fundamental software’s source code.

Unfortunately, if you are a business who plans on operating numerous forums or a hosting company looking to offer a “value added” service to your customers, $85 per year, per license can add up. The choice was obvious for our forum software needs.

Tags: , , ,

Hello world!

Posted by Dev Team December 2nd, 2007

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!