I am pulling my hair out. I am trying to enable SEF URLs for my Drupal site. I have read all the forums, contacted my web host and successfully proved mod_rewrite is installed and working.

I uploaded .htaccess file to the root of my webserver.

RewriteEngine On
RewriteRule ^test.html$ /test2.html [R=301]

I created file test.html and test2.html and then I fired up firefox and went to www.mysite.com/test.html and it routed me to test2.html, Success mod_rewrite is working no?

I then uploaded the default .htacess file to the root of www.mysite.com and went to administer/settings and poked Clean URLS - enable and saved. I then got this message. "It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator."

Man, I can't figure this out.

Comments

mattwalston’s picture

I was not able to reproduct the error on another site, but I ended up getting everything working by uncommenting the rewrite base and making sure it was set to /. Good luck!

Matt Walston

Barleyman’s picture

Thank you Matt.

That was the ticket, uncomment rewritebase and add "/"

RewriteBase /

Still some hair left.

Why did we have to do this?

mattwalston’s picture

What is your drupal and apache versions?

Matt Walston

heine’s picture

About Rewritebase & mod_rewrite:

When a substitution occurs for a new URL, this module has to re-inject the URL into the server processing. To be able to do this it needs to know what the corresponding URL-prefix or URL-base is. By default this prefix is the corresponding filepath itself. But at most websites URLs are NOT directly related to physical filename paths, so this assumption will usually be wrong! There you have to use the RewriteBase directive to specify the correct URL-prefix

From the mod_rewrite docs.

(edit: link)

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

mattwalston’s picture

That explains the problem, but why should the .htaccess be broken for most people be default, why not just uncomment one line in the example? Should this be changed for next version?

Matt Walston

heine’s picture

Do you have data that shows .htaccess is 'broken' for most people or is this an assumption you make?

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

mattwalston’s picture

Would it not have the same out of box functionality if it set the base to / that if it was left unset? I know very little about mod_rewrite, but it should improve support if it was set to / by default. I know it took me an hour of fooling around to fix yesterday, and I have probably done 50+ installs of drupal as the / of a site. Yesterday was the first problem, even with server in identical config, literally, just coppied and renamed a new name based virtual host and made a new dir from the skeleton.

Matt Walston

oadaeh’s picture

It has worked out of the box for me for every site I've created (something around 20). Granted, they've only been on three different servers, and two of them I setup...