Skip to main content
Ryan Price and the Media
Commanding Chaos for Coworking, Open Source and Creative Communities

Main navigation

  • Blog
  • About
  • Contact
  • Subscribe
  • Drupal Easy
  • Florida Creatives
  • Liberatr
  • Lifestream
  • ThinkUp
  • Home
User account menu
  • Log in

Breadcrumb

  1. Home
  2. How I Got My Mod_rewrite To Play Nice With Apache 2 and Drupal

How I got my mod_rewrite to play nice with Apache 2 and Drupal

By rprice , 16 September 2006
Categories
HowTo
Tech
Tags
Drupal
SEO

Ramon (not verified)

18 years 4 months ago

I was trying to get it to

I was trying to get it to work but was missing the "AllowOverride All" directive. Your post pointed that out. Thanks.

I have been installing Drupal sites like crazy recently, and one thing that really helps a Drupal site thrive is the Clean URLs feature. Clean URLs and smart permalinks and all sorts of things require Apache's wonderful mod_rewrite to be active. This isn't very hard, but it is if you don't know what you're doing.

This HowTo assumes that you have control over your entire server. If you don't, you need to contact your hosting support, or whichever geeky cousin you are getting your hosting from.

Here are three easy steps to enable search-engine-friendly URLs:

  1. Enable mod_rewrite in your /etc/httpd/conf/httpd.conf
    Notice: Screwing up this file will break your Apache server, so before you proceed, make sure you make a copy of your .conf file:
    ? cp httpd.conf httpd.conf.bak

    Then check for this line near the top of your file. It will be just after some comments referring to DSO, and a whole bunch of LoadModule statements.
    #
    # Dynamic Shared Object (DSO) Support
    #
    ...
    LoadModule rewrite_module modules/mod_rewrite.so
  2. Allow .htaccess files to override universal rules.
    This is the meat of this tutorial. Local directories need to be able to override the defaults and add their own RewriteRules. You put this in your file where you are setting up options for your root web directory. For my specific configuration, I had to put it in the first (/) one and not the next (/var/www/html) one. I tried them both.
    #
    # Each directory to which Apache has access can be configured with respect
    # to which services and features are allowed and/or disabled in that
    # directory (and its subdirectories).
    #
    # First, we configure the "default" to be a very restrictive set of
    # features.
    #
    Options FollowSymLinks
    AllowOverride All
  3. Don't forget to restart Apache!
    You need to restart Apache so it will read in the new logs and restart all the processes. Every single change you make to the .conf file means you need to restart Apache. The changes won't apply otherwise. On my system, this was a simple matter of entering the following command:
    ? apachectl -k graceful
    This is the "nice" way of shutting down and restarting Apache.
  4. Set your RewriteBase directory in your .htaccess file (maybe)
    If you're running multiple installs of Drupal on the same domain like me, you may also need to make a change in your .htaccess file in your base Drupal directory.If your install base is www.example.com/portal, you will need to find this line:
    #RewriteBase /drupal
    ...and change it so it reads:
    RewriteBase /portal

That's it! Once you've done this, navigate to your admin page, like http://www.example.com/admin/settings/clean-urls and check the radio button for "Enabled". If you did something wrong, the page won't load, and you'll know something went wrong.

Hope this helps! You can get more detailed information at drupal>>node/84496

The steps in this HowTo should also help if you are installing another piece of web software like Menalto Gallery 2, Wordpress, or Mambo/Joomla.

Twitter / liberatrRyan Price | Facebook Flickr: Photos from Liberatr.netInstagramYouTube :: Videos by liberatrLinkedIn: Ryan Price

I am nobody's puppet.

Disclaimer: My blogs are not a reflection of my employer's opinions, but are my own, and often unfiltered. Also, some links on this site may be part of an Amazon Associates program, so by clicking on them you help me pay for my independence.

Drupal Association - Individual Member Acquia Certified Developer Acquia Certified Developer Miro Video Player | Download torrents and podcasts, play any video, and do it with style. Gimp - a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. Processing is an electronic sketchbook for developing ideas. Build a custom arts management solution. LibreOffice is the free power-packed personal productivity suite that gives you six feature-rich applications for all your document production and data processing needs

  • Thanks again, Steve. I hope
    14 years 1 month ago
  • Hi - bit late responding here
    14 years 1 month ago
  • Should have added...
    14 years 2 months ago
  • Hi Ryan,
    14 years 2 months ago
  • Ryan,
    14 years 2 months ago
  • It is happening and you are
    14 years 5 months ago
  • In close future I want to
    14 years 8 months ago
  • the article has been
    14 years 9 months ago
  • I think it's a great coup for
    14 years 9 months ago
  • My hardware box acts as an
    14 years 10 months ago

  • Blogging Fringe
  • Bringing Art and Technology Together
  • Drupal Easy Podcast
  • Florida Creatives Podcast
  • Invisible Frisbee
  • Liberatr.net Facebook
  • Liberatr.net
  • Orlando Podcasters
  • Orlando Scene TV
  • Orlando Video
  • Our Yellow House
  • Pulpp.net Orlando Blogs
  • Pulpp.org Real-Time Collaboration
  • Shrink Your Ecological Footprint
  • The Student of the Game

  • Alex Rudloff
  • Apartment E
  • Brian Feldman
  • Chad Miller
  • Charles Krueger
  • Chris Messina
  • Chris Scott
  • Chris Wojda
  • Daniel H. Pink
  • Daniel Smith
  • Darren McDaniel
  • David Terrar
  • Destination Journal
  • Dr. XNLB
  • Elizabeth Maupin
  • Eric Marden
  • Hugh McLeod
  • Jana Waring
  • Jeremy Harrington
  • John Rife
  • Josh Hallet
  • Katie Ball
  • Katharine Miller
  • Lloyd Davis
  • Loren Feldman
  • marc. with a c.
  • Marc Rapp
  • Mario Andy Lurig
  • Mark Baratelli
  • Mike G
  • Noel Hidalgo
  • PSFK
  • Rebekah Lane
  • Stephen Matheny
  • Thomas Thorspecken
  • Tim Welch

  • Florida Drupal Group
  • Izon Orlando
  • Orlando Coworking
  • Orlando Fringe
  • Orlando Improv Festival
  • Orlando PHP
  • Orlando Puppet Festival
  • Page 15
  • The Daily City
  • Urban ReThink

Powered by Drupal

<none>

  • RSS Feed