Webmaster Help bookmark Demon
|
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jan 06, 2009, 05:53:33 AM

Login with username, password and session length

Men do less than they ought, unless they do all they can.


- Thomas Carlyle

Welcome Guest - Register or Login Now to remove these advertisments


Registration is completely free and only takes a few minutes to signup !

|-   Entrepreneur Forum > Webmasters - Discuss Making Money Online > Content Management Systems
+   Clean URL's for Drupal using .htaccess file
0 Members and 5 Guests are viewing this topic.
Pages: [1] Reply to Thread
Author Topic: Clean URL's for Drupal using .htaccess file  (Read 315 times)
Online~Dave~
Administrator
~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough~Dave~ is a jewel in the rough
Joined: Jan 2006
Posts: 6186


Avatar of code4gol

Building a Foundation

View ~Dave~\s ProfileWWW
Gender: MaleGemini United States
notepad Aug 17, 2008, 01:42:53 PM #1
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

Quote
#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# 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.
<Files favicon.ico>
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

# 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.
<IfModule mod_php5.c>
  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
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # 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
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  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]
</IfModule>

# $Id: .htaccess,v 1.93 2008/06/28 19:48:21 dries Exp $


That's all there is to it !!



Latest Blog Post : Social Media Optimization for Social Media Marketing

OfflineRichKid
Pro Member
RichKid is on a distinguished road
Joined: Jan 2007
Posts: 519


Avatar of RichKid

View RichKid\s ProfileWWW
Gender: MalePisces Brazil
notepad Aug 18, 2008, 08:01:30 PM #2
I tried Drupal for about 3 hours and got nowhere with it so I deleted it and went back to Wordpress.

Pages: [1] Reply to Thread


Code4Gold Affiliate Entrepreneur Moneymaker Forum © 2006-2008 Resdaz Media LLC - All Rights Reserved

Forum Software Powered by SMF - © 2001-2008, Lewis Media. All Rights Reserved.