Fixing Apache on CentOS/RHEL 5 for Drupal
While not strictly a requirement, in the interests of not having crazy URLs on your site it's recommended to set up your web server to support files. This will let you have URLs like "/products/cool/stuff" instead of "?q=products/cool/stuff" - obviously much nicer, and better for both usability and search engine optimization. Well unfortunately on 5 (RHEL) and 5 (which is basically the same as RHEL) the standard web server, , is set to ignore these files. So here's how to fix it.
Whether you're configuring the virtual host in a separate file or in the main httpd.conf, the change you'll want to make is the same:
Step 1: enabling .htaccess files:
- In the main httpd.conf file (should be at /etc/httpd/conf/httpd.conf) search for the string "AccessFileName",
- If the line is commented out (it starts with "#") uncomment the line by removing the "#" symbol,
- Update the line to say:
AccessFileName .htaccess
- Restart Apache, reload the site and.. enjoy the error message :-)
- On to the second part..
Step 2: allowing .htaccess files to override settings:
- Find the configuration for the Drupal site,
- There should be a <Directory> section within that block,
- If there isn't a line that starts with AllowOverride, add a new one within the <Directory> block,
- Set the AllowOverride line to the following:
AllowOverride Options Indexes Limit FileInfo
- Restart Apache again.
- Et voila.
This will allow the Drupal .htaccess file to run and make your URLs all nice & shiny!


Comments
1 comment postedResearching this topic over the last few weeks has been a tedious task and your information is well organized and right on topic. I enjoyed reading your post. Do you have any others on this subject?
Post new comment