I have read all the forum posts about mod_rewrite and the .htaccess file and have tried every alteration I can think of, but I still can't get mod_rewrite to do anything. I have run phpinfo() and can confirm that the mod_rewrite module is installed on my web server, which is Apache2. I am currently doing development work on my local machine (running Fedora 8), so my base url is http://localhost.localdomain and my drupal installations are located at http://localhost.localdomain/drupal-5 and http://localhost.localdomain/drupal-6 respectively as far as Apache is concerned, but physically, the files are located at /var/www/html/drupal-5 and /var/www/html/drupal-6. I have tried the following alterations to my drupal-5 installation and the same changes were also unsuccessfully tried on my drupal-6 installation:

1. .htaccess file:
Commenting out RewriteBase
Changing RewriteBase to
Changing RewriteBase to /
Changing RewriteBase to /drupal-5
Changing RewriteBase to /drupal-5/
Changing RewriteBase to localhost.localdomain/drupal-5
Changing RewriteBase to localhost.localdomain/drupal-5/
Changing RewriteBase to /var/www/html/drupal-5
Changing RewriteBase to /var/www/html/drupal-5/
Commenting out the starting and ending if... /if lines that make the rewrite block conditional (ie, to make sure it always executes)

2. httpd.conf file:
Changing DocumentRoot to /var/www/html
Changing DocumentRoot to /var/www/html/

So if anyone can suggest anything I might have overlooked, please reply to this.
I have also enabled the Path module, even though I don't think it is anything to do with mod_rewrite (Path addresses a different issue)

Comments

suit4’s picture

I always start developing my sites on localhost and all the time, in my .htaccess-File (is yours named DOThtaccess?), RewriteBase is commented out.

That should work for http://localhost/myDevelopmentSite

It should have to do nothing with DocumentRoot.

Tried to access your page via http://127.0.0.1/drupal-5 ?

Do you pass the test for mod_rewrite during Drupa 5 setup?

manObject’s picture

Thanks, suit4

As you have seen, I have been trying even illogical solutions!

The filename is definitely DOThtaccess

I've checked that the file's group permissions are set to apache: read + execute

Using 127.0.0.1 instead of localhost made no difference.

I've commented out RewriteBase and yes, the mod_rewrite module is present and correct (ticks all the way in Status Report page)

The only other thing I can think of that might be causing a hitch is SELinux, but I'm not getting any error messages or log entries and the SELinux Context for the file seems correct ("Read from all httpd scripts and the daemon").

It must be something so obvious... but what?

bwill’s picture

I also had issues trying to get clean urls to run on localhost. Here are the suggestions given to me:

Inside the httpd.conf file uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (remove the pound '#' sign from in front of the line)
Also find the line ClearModuleList is uncommented then find and make sure that the line AddModule mod_rewrite.c is not commented out.

Your Rewrite base seems to be set correctly - RewriteBase/drupal-5 - this will need to be commented out when uploading to your host.

Restart Apache server afterwards - very important

Read this post - http://drupal.org/node/15365 especially the comment "Here is what I did to get Clean URLs working on my testbed rtivel - August 25, 2007 - 22:25"

manObject’s picture

Thanks bwill

Actually, my version of Apache (Apache2.2 for Fedora 8) came with all the modules ready loaded in httpd.conf, so there was nothing to uncomment in the entire LoadModule block. Looks like my version is a slightly different beast to yours.

There is no 'ClearModuleList' directive and no AddModule mod_rewrite.c directive to uncomment. When I tried to add the AddModule mod_rewrite.c directive, Apache refused to start and threw an error. Anyway, I know that the mod_rewrite module is installed because I ran phpinfo() and it was included in the list of installed modules.

Hey ho, thanks again, but its back to the drawing board for me...

arh1’s picture

these days i always use Apache virtual hosts so that the dev/staging and live sites are peers of each other (e.g. http://dev.example.com runs on my local machine while http://example.com runs on the remote server). if you can pull that off, i'd highly recommend it as it'll make your content more portable between sites...

anyway, i think in your .htaccess file you can leave the RewriteBase line alone and focus on the RewriteRule line. something like:

RewriteRule ^(.*)$ /drupal-5/index.php?q=$1 [L,QSA]
OwlsNest’s picture

Delete # from RewriteBase / in htaccess

This worked for me.

I was having a hard time getting a Drupal 5 site that is hosted with GoDaddy in a subdirectory to pass the clean url's test. I modified the htaccess file - I simply deleted the # from the line RewriteBase / - it is working now.