ModRewrite check doesn't work

fuzzydru - April 18, 2005 - 22:34

Installed the 4.6.0 version without any problems with one exeption:
the Settings Page keeps giving me the

"It appears your host is not configured correctly for Clean URLs. Please check for ModRewrite support with your administrator."

message even though i know the webserver is set with the "Module Rewrite".

maybe someone has any idea to that issue since i dont wanna go to my provider with something he can't fix. ;)

same problem

crashtron - April 20, 2005 - 08:11

i have the same problem. I uploaded the .htaccess and controlled that mod_rewrite is installed on the server with phpinfo(). When i want to activate clean_url i get the same error message

maybe cpu overload or cache or whatever

micha_1977 - April 20, 2005 - 09:18

i had the error too, tried it again after some seconds and then it worked

-micha
work in progress with Drupal 4.6: langmi.de

beleive me

chx - April 20, 2005 - 10:42

It does not work. You may need a RewriteBase or a / in front of index.php in the rewrite rule or both.

Works with the slash!

nielses - August 8, 2005 - 13:22

It works for me after adding a slash in front of index.php like this:

RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

Thank you!!

I would like to understand why it works, but right now I'm happy..!

do not work!

hdhd - August 31, 2005 - 16:38

I have got the drupal 4.5 installed in the same server that I installed the 4.63 drupal. In the 4.5 the clear urls works fine. But in the 4.63 release it has not worked.
I tried to follow the thread here. it s not working even when I put on and out slashes and so on. I tried to use the $conf['clean_url'] = 1; but it has not worked properly.
I have installed in a 46/ directory. Does someone has an idea to change the htaccess????

RewriteEngine on

now the htaccess is like that:::
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]

Worked but

apolo - December 2, 2005 - 07:14

It worked for me. But now my "clean" URL turn back to the
?PHPSESSID problem which I solved before by CHMOD 777 on /session folder.

Ideas?

It worked!

gilsmethod - April 3, 2006 - 15:21

I tried the slash in front of the index....and it works great.
Thanks!

Visit My Drupal Site www.gilsmethod.com and tell me what you think!

doesn't look like its working to me

jeditdog - April 19, 2006 - 01:51

Hey I clicked on some of your links and it hasn't been clean URL's (in your how to section). What link should I click specifically?

well, i know the ModRewrite

fuzzydru - April 20, 2005 - 14:32

well, i know the ModRewrite is enabled on the server since i use it in an other script (Gallery2).
maybe, the detection for it in Drupal is not 'clean' enough.

hm

chx - April 20, 2005 - 15:57

I can only repeat my previous comment. Here's what clean url checker does: it tries to download system/test/randomname.png. That's a dynamically generated picture, and during the generation it sets a flag that clean URLs work. If you can not reach system/test/whatever, you won't reach other pages too.

You can always see for yourself, try to delete ?q= from the URL and see what happens. If you get the page you expect, then clean URLs work.

More info

Steven - June 7, 2005 - 03:14

Chx is right (he thought of the current test). Note however that the .png will not return a real image... all you need to check is whether it 404s or not.

The Clean URL option in Drupal only sets whether Drupal outputs clean URLs. If your .htaccess and mod_rewrite is correctly configured, they should already work if you manually remove the ?q= from a page. Try it. If it doesn't return a "page not found", then you have a very exotic server configuration.

--
If you have a problem, please search before posting a question.

confabulated

ylbissop - August 15, 2005 - 11:55

i don't see these temp.png files being created at all.
the modRewrite rules i have in place work. I'm sure of it because i even removed them and then fixed them again just to check.

http://ylbissop.com/life/?q=node/186
and
http://ylbissop.com/life/node/186
show the same page.

http://ylbissop.com/life/system/test/
throws a 403.

and http://ylbissop.com/life/system/test/doesnotexist.png
gives me a 404.

my only idea is that possibly drupal cannot write to the test directory ??
but it's not a chmod problem
drwxrwxrwx 2 ylbissop users 6 Aug 15 02:56 test

so what is it?
any help would be great.

thanks in advance!

finally figured out how to

ylbissop - August 18, 2005 - 11:49

finally figured out how to force clean url's on.
and it worked
if you need to do this simply add

$conf['clean_url'] = 1;

near the end of your settings.php.

hope it helps

Thanks

promete - October 13, 2005 - 22:28

Thanks for your replyi it solved my problem

But I am still having problem

mmtahir - October 14, 2005 - 16:13

Yes it shows the clean URLs but the link goes no where except a Not Found page.

Moreover, It is still unable to turn on clean URLs from the administer/settings page.

Don't know why?

Saeed

Just modify the Apache httpd.conf

chweifly - June 7, 2005 - 01:50

Just modify the Apache httpd.conf:

Options FollowSymLinks
AllowOverride all

Remember any VirtualHost sections

gorgen - August 5, 2005 - 13:45

Remember to check the AllowOverride option in your VirtualHost section too, if you have one.. That was my problem..

Georg

ModRewrite not working

boots - June 8, 2005 - 20:14

I had this problem, too. I knew that mod_rewrite was installed, but I kept getting the same error you did. Here's the issue:

Drupal uses the .htaccess file in your top-level drupal folder to tell the webserver to create the Clean URL rules. However, the webserver only looks at .htaccess files if an "AllowOveride All" option is set in the main httpd.conf file. Here's a section of httpd.conf so you can see what it needs to look like:

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/home/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
#
for more information.
#
    Options Indexes FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride All

#

Hope that helps... If you're running your own server, you can fix that yourself, otherwise you'll have to convince your provider to allow your .htaccess overrides.

Ok - What now?

hobbsm - June 27, 2005 - 10:12

Hi All,

These posts were of great use to me as I was going out of my mind with apache, I had installed it (apache 2.0.54) about eight times and couldn't work out what I was doing wrong.

Ok, so I've made the above changes in the httpd.conf - I have then checked clean URLs work by removing the ?q= from a path. However in the Drupal site configuration, it still won't let me turn the option on.

Any ideas?

Cheers,
Mike

clean URL .htaccess settings

ymcp - June 28, 2005 - 10:05

Hi Mike,

I am currently evaluating Drupal (4.6.1) and was also having trouble getting clean URLs to work. It is installed in a "drupal" subdirectory on my 1&1 (http://www.1and1.co.uk) web server. It is now working great... it just needed a few changes to the .htaccess file:

1. Uncomment the RewriteBase /drupal line.
2. Change the "RewriteRule" line to read:
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]
3. Go to "administer->settings" and enable Clean URLs.

I hope this helps...
Yuri

Still no joy

hobbsm - June 28, 2005 - 14:26

Hi Yuri,

Thanks for the advice, unfortunately it is not relevant to my problem. I have not installed Drupal in a sub directory. Even if I have, it's not that the rewrite rule doesn't work, but the fact that I can't actually get that far!!

I have today re-compiled a new instance of apache 2.0.54, freshly downloaded and untarred into a completely directory - To prevent any cross-contamination from old installs. I then run:

./configure --prefix=/apache2 --enable-so --enable-rewrite --with-perl --with-mysql

After this completes I check config.log in that directory and see this in the file:

configure:15625: checking whether to enable mod_userdir
configure:15663: result: yes (default)
configure:15711: checking whether to enable mod_alias
configure:15749: result: yes (default)
configure:15798: checking whether to enable mod_rewrite
configure:15836: result: yes (default)
configure:15949: checking whether to enable mod_so
configure:15987: result: yes

As you can see mod_rewrite is definately compiled into it, but after running make and make install, respectivley, there appears to be no modules in the /apache2/modules directory. I've done this many times on different PCs and servers and they never appear. I can only assume it's somehow built in.

But regardless of where apache hides it, I still cannot turn Clean URLs on through the administer> settings section of my drupal instance...

Help. :o(

Mike

Fixed it

hobbsm - June 29, 2005 - 08:39

Basically apache2 does compile the modules in, depending at what was specified at ./configure, handy hint, to check what's built in run ./httpd -l (lowercase L) from apache's bin directory

Thanks for all the help peeps!

I just checked my compiled

rgladwell - August 14, 2005 - 14:32

I just checked my compiled in httpd modules as above and mod_rewrite.c was not listed. However, when I run apache_get_modules mod_rewrite is listed there! What does this mean?

thanks

leansy - August 8, 2008 - 23:57

thanks, this solutions work perfect for me.

Leansy Alfonso Pérez
Linux User #191373

Fix

rgladwell - August 15, 2005 - 11:08

The fix for this is simply checking that all the AllowOverride options for the drupal install directory in your Apache httpd.conf are set to All. This is mentioned in a comment on the Clean URLs documenation page. The Clean URLs documentation, and the application should be updated to reflect this.

Hey, that's nice...

drinkypoo - February 21, 2006 - 21:20

It should mention explicitly (as does a prior comment) that you have to check both your <Directory /> section, and the same thing for any Virtual Hosts you may have. In particular most Apache2 installs (say, when you install the Apache dist from your distro) are set up for vhosts out of the box.

pls help - mod_rewrite problems too

vkero - August 22, 2005 - 17:14

I am attempting to get mod_rewrite working with my drupal install here too. Does not seem to be working. Here is my RewriteError log:

127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (2) init rewrite engine with requested uri /page-test
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (3) applying pattern '^(.*)$' to uri '/page-test'
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (4) RewriteCond: input='/page-test' pattern='!-f' => matched
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (4) RewriteCond: input='/page-test' pattern='!-d' => matched
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (2) rewrite /page-test -> index.php?q=/page-test
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (3) split uri=index.php?q=/page-test -> uri=index.php, args=q=/page-test
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec73b0/initial] (2) local path result: index.php
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (2) init rewrite engine with requested uri /error/HTTP_BAD_REQUEST.html.var
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (3) applying pattern '^(.*)$' to uri '/error/HTTP_BAD_REQUEST.html.var'
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (4) RewriteCond: input='/error/HTTP_BAD_REQUEST.html.var' pattern='!-f' => matched
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (4) RewriteCond: input='/error/HTTP_BAD_REQUEST.html.var' pattern='!-d' => matched
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (2) rewrite /error/HTTP_BAD_REQUEST.html.var -> index.php?q=/error/HTTP_BAD_REQUEST.html.var
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (3) split uri=index.php?q=/error/HTTP_BAD_REQUEST.html.var -> uri=index.php, args=q=/error/HTTP_BAD_REQUEST.html.var
127.0.0.1 - - [22/Aug/2005:05:50:07 --0400] [foo.local/sid#88d498][rid#4ec88e0/initial/redir#1] (2) local path result: index.php

if somebody could help that would be great.
TIA
vaughn

FIX

eokyere - August 23, 2005 - 06:24

I had similar problems... the RewriteConds in the .htaccess file should be changed from:

[old]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 

to:

[new]

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d

In the first instance, for me at least, every argument passed to it was a match, which meant the url was always rewritten (even for paths that existed). Adding document root to the request filename fixed this.

My rewrite rule now looks like this: (trivial change with the forward slashes)

RewriteRule ^/(.*)$ /index.php?q=$1 [L,QSA]

HTH,
eokyere

Confirmed Parent Fix

zariok - September 9, 2005 - 23:39

This worked with my installation on Fedora Core 2 using VirtualHost on Apache v2.0.51 / PHP v4.3.10

My .htaccess file has the RewriteBase set to /

[/etc/httpd/conf.d/virtualhost.conf]

NameVirtualHost *:80
<VirtualHost *:80>
  ServerAdmin admin@example.com
  DocumentRoot /websites/drupal.example.com/html
  ServerName drupal.example.com
  ErrorLog logs/drupal.example.com-error_log
  CustomLog logs/drupal.example.com-access_log common
</VirtualHost>
<Directory "/websites/drupal.example.com/html">
  Options Indexes FollowSymLinks
  AllowOverride All
</Directory>

EDIT:
The parent fix allowed for the drupal to say CleanURLs were configured, but i kept getting errors (File does not exist - apache error log) until i reverted the .htaccess. Now it works as described.

Clean URLs on Debian/Apache2

tiff - October 5, 2005 - 01:00

Here's what I had to do to get mod_rewrite working with Drupal 4.6.3 on a Debian Testing box under Apache2. This solution assumes you have access to the apache2 configuration files (which probably means root access to the server).

1. Check that mod_rewrite is enabled. You can check with the following:

root@server[~]# a2enmod rewrite

This will either enable mod_rewrite, or will tell you it's already enabled.

2. Next, you need to edit the Apache2 configuration files so it will pay attention to .htaccess files, like the one provided with Drupal which configures the clean URL feature.

Edit /etc/apache2/sites-enabled/000-default. After the line:

<Directory /var/www>

edit the line

AllowOverride None

to

AllowOverride All

3. Restart Apache:
root@server[~]# /etc/init.d/apache2 force-reload

-- T.

It works!

vigo - October 7, 2005 - 10:46

Thanks tiff - been trying to get clean URLs to work, now perfect. Cheers!

localhost / WinXP / Apache2 / Drupal 4.6 / PHP 4.3.10 / MySQL4.1

jastek - October 9, 2005 - 15:07

So I was having a lot of problems trying to get cleanURLs to work, and I was trying all the stuff you guys were saying in this thread. I finally went to bed last night out of frustration... but today, I woke up and got it working easily.

My problem:

I was changing the wrong "AllowOverride" in Apache2's "httpd.conf" file.

If anyone's still having problems, make sure you change the correct AllowOverride.

Here's the default "httpd.conf" from my recent installation starting at line 270:

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

----------
I needed to change line 274 from:
AllowOverride None
to:
AllowOverride All
----------

Thanks for everyone's help...

VirtualDocumentRoot breaks mod_rewrite

paul@murphymaph... - February 10, 2006 - 18:29

On XP, Apache2, Drupal 4.6 I also could not get clean URL's working. mod_rewrite was enabled, AllowOverride All was set.

I had a VirtualDocumentRoot rule in place on the site however. Once I set up a specific VirtualHost entry for this site (rather than VirtualDocumentRoot redirecting based on it's rule) mod_rewrite began to work as expected.

Paul Murphy
http://murphymaphia.com

VirtualDocumentRoot breaks RewriteBase

JohnAlbin - March 15, 2006 - 17:52

Actually, the problem and solution are simpler than Paul thinks. Apache's VirtualDocumentRoot causes mod_rewrite to set an incorrect default value for RewriteBase.

Simply edit drupal's .htaccess file and uncomment and change this line:
#RewriteBase /drupal to the proper value. In my case, it was RewriteBase /.

- John

Thanks, John

paul@murphymaph... - March 17, 2006 - 23:46

I figured that out along the way but should have posted the solution.

Thanks for posting the solution

Wrong AllowOverride

RobinD@drupal.org - June 2, 2006 - 12:14

Thanks for this post, set me off in what turned out to be the right direction..

I worked through each of the six AllowOverride's and eventually it works !!

the previous posts indicating which AllowOverride to use was wrong for me,

Thanks for the steer

RobinD

Enfin!!!

Chill35 - December 11, 2006 - 01:36

jastek, thank you!

# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

----------
I needed to change line 274 from:
AllowOverride None
to:
AllowOverride All
----------

Like you, my AllowOverride was set to None.

On most hosts how is that set ?

This should be in the doc.

Now it works!!!

Caroline

Still wasn't working but...

alexkb - October 13, 2005 - 05:47

When trying to enable the Clear URL feature, I recommend the following (if you are still having troubles):

[1] Make sure you have the original .htaccess file (~67 lines) from your drupal tar (for some reason mine got changed).
[2] When you confirm [1], log out of the admin area, close browser (closing the session), and re-login again.

This is assuming you have mod_rewrite installed properly, and have the correct Options and AllowOverrite enabled.

Clean URLs Works Fine in Apache/MySql/PHP (But...)

mmtahir - October 13, 2005 - 18:21

I have configured Drupal at my local host in a sub directory and Clean URL works fine after doing the following configuration:
-------------------------------------
>> Apache configuration:
----------------------------------------------
>> edit httpd.conf file:

>> find and uncomment it:
AddModule mod_rewrite.c

>> find and uncomment it:
LoadModule rewrite_module modules/mod_rewrite.so

>>.htaccess configuration:
----------------------------------------------
>> Open .htaccess file (in the drupal root)
>> find and uncomment the following lines

RewriteEngine on

# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
RewriteBase /drupal #(where drupal is the name of subdirectory where drupal is installed)

# Rewrite old-style URLs of the form 'node.php?id=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^id=([^&]+)$
RewriteRule node.php index.php?q=node/view/%1 [L]

# Rewrite old-style URLs of the form 'module.php?mod=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
RewriteRule module.php index.php?q=%1 [L]

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

>> Drupal Engine Settings
------------------------------------------------
>>Open drupal site: >> Administer >> Settings
Change option to set Clean Urls: Enabled
-----------------------------------------------

(But...) the real problem is when I try it on my remote-server (IIS Based) where .htaccess file is not working. I have searched some forums and they were telling about ISAPI Filters that goes of my head. Looking for some neat and easy alternative. So if any one has any Idea, it will be much appriciatable.

thanks

Saeed

Got it working a different way!

HumanCell - October 17, 2005 - 05:14

I have tried all of the various suggestions in this thread, however it *still* was not working for me. In my case, I have the root directory of my virtual web server pointing to the drupal directory. Upon rereading the mod_rewrite docs here:

http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteBase

I edited the .htaccess file in my drupal install directory. I changed the RewriteBase directive to be the root URL path as shown in the snippet below:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal  # I commented this line
  RewriteBase /         # I added this line

Upon again changing the settings for Clean URLs to Enable ... it worked!

P.S. I also had added the following to my httpd.conf:

<Directory "/var/www/drupal-4.6.3">
    AllowOverride All
    Options FollowSymLinks
</Directory>

mod_rewrite error removal with xampp in a Winbox.

whizy - January 30, 2006 - 21:02

Just wanna share my two-cents on how I got rid of the pesky mod_rewrite error while attempting to enable clean URL. I'm running an apache server via the xampp package on windows XP. Firstly, I opened the htaccess file in the drupal folder, proceeded to line 47, and removed the comment by deleting the # sign (see example):

#RewriteBase /drupal (before)
RewriteBase /drupal (after)

I then proceeded back out to the xampp folder, navigated to the apache folder therein, opened the conf folder, opened the httpd.conf file, and removed the comment infront of line 168 (see example again):

#LoadModule rewrite_module modules/mod_rewrite.so (before)
LoadModule rewrite_module modules/mod_rewrite.so (after)

After this is done, I shut-down the apache server and re-started it once more. Upon selecting the enable clean URL radio button, everything worked out. Hope my two-cents will save a couple of hair strands from being pulled out.

 
 

Drupal is a registered trademark of Dries Buytaert.