Just installed Drupal, default setup on apache/mysql (including mod_rewrite), tried the clean URLs configuration from the admin area and got stuck.

The clean URLs page loads, ending at the button "Run the clean URLs test", which I press, and the page reloads as it is.

From checking my logs, it starts at this page:
/?q=admin/config/search/clean-urls&render=overlay&render=overlay

Then tries to run this:
/admin/config/search/clean-urls/check

Which is a 404, as clean URLs aren't enabled yet! It then returns the first page without error.

I hope this is ok as a bug report, it's my first one...

CommentFileSizeAuthor
#42 htaccess.txt5.28 KBchitwarnie
#26 clean_url_test_fails.gif68.21 KBdrupalastic
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

heatherwoz’s picture

Similar problem. There is no button to enable/disable clean urls, so I can't change the setting.

rafamd’s picture

Same to me from a clean install.

heatherwoz’s picture

Title: Clean URLs test fails - can't enable them. » Clean URLs test fails - can't enable or disable them
Priority: Normal » Major

So it seems that the button to enable/disable does not appear at all if the server doesn't support clean URLs. It became available once we corrected the configuration. But it needs to be there always, in case the server configuration is changed and clean URLs need to be turned off. If clean URLs cannot be disabled this can impact the functionality of the whole site.

rafamd’s picture

@heatherzwoz, do you see the button ? Because my server does support clean urls. I had them enabled with alphas 5, 6 and 7. I suppose the button doesn't show at all. Thought of changing this to critical but I'm leaving this for someone with more "authority" :)

OsterD’s picture

Same here!!!
I have a fresh install of 7.0-beta1.
Runs as a Virtual Host exactly the same configuration on vhosts file and htaccess of another Drupal 7.0-dev from DrupalGardens.
Behaviour is exactly the same as previous people.

OsterD’s picture

Even with version 7.0-beta2 same problem exists.

AnalogFile’s picture

Version: 7.0-beta1 » 7.x-dev

Tested with beta and with HEAD and they behave the same, therefore moving this to 7.x-dev

The title is probably wrong because once you do get it to the point where the test succeeds, the checkbox is shown even if you then change the server config back, therefore #3 assumption may be wrong.
However there's something fishy here, and I'm leaving the title as is for the moment.

Description of my test and observed behavior
  • action: wiped DB with phpMyAdmin
  • action: cvs update -dP
  • action: edited .htaccess line 63 to "RewriteEngine off" to simulate non working clean urls
  • action: point browser to install.php?profile=standard&locale=en
    • (expected) result: Drupal installs and takes me to the "Configure site step"
  • action: fill up the form and submit
    • (expected) result: Drupal finishes install
  • action: point browser to ?q=admin/config/search/clean-urls
    • (expected) result: Drupal takes me to the clean-urls config (note: no overlay as I pointed it directly there)
    • (expected) result: the page sports the "Run the clean URL test" button and no checkbox
  • action: dumped DB with phpMyAdmin
  • action: edited .htaccess line 63 to "RewriteEngine on"
  • action: reloaded browser page (still pointing to ?q=admin/config/search/clean-urls)
    • (expected) result: the page now sports the (unchecked) checkbox and there's no more a "Run the clean URL test"
    • NOTE: this means that loading the page itself did run the test and the test succeeded, but the user is not notified of this fact and does not see a "Run the clean URL test" to check it if she is not sure
  • action: dumped DB with phpMyAdmin and diffed with previous dump
    • result: changes are all related to cache tables and to the time the user session.
      • detail: cache_bootstrap table changed
        • detail: there's a new row with cid='variables'
      • detail: cachemenu table changed
        • detail: there's a new row with cid='links:management:page:admin/config/search/clean-urls:en:1:0:trail'
        • detail: there're two new rows with cid='links:management:tree-data:en:...' where the ... represent some long hex value (a hash, I suppose)
        • detail: there're two new rows with cid='menu_item:...' where the ... represent some long hex value (a hash, I suppose)
      • detail: sessions table changed
        • detail: the data for the user session is changed
      • detail: users table changed
        • detail: the data for the access column of user 1 changed
  • action: edited .htaccess line 63 to "RewriteEngine off" again
  • action: reloaded browser page (still pointing to ?q=admin/config/search/clean-urls)
    • (UNEXPECTED) result: the page still sports the (unchecked) checkbox and there's no "Run the clean URL test"
    • NOTE: this means that somehow this time around the page load did not run the test (or the test is broken, or what the page did with the test result is unexpected)
  • action: dumped DB with phpMyAdmin and diffed with previous dump
    • result: no changes in cache related tables. Only the session and user table changes are there.
    • NOTE: I suspect that there may be something in cache_bootstrap table's row with cid='variables' that's related to the unexpected behaviour, but I do not know PHP well enough to spot where the problem is in code.
  • action: point browser to ?q=admin/config/development/performance
    • (expected) result: the performance settings page is displayed
  • action: click on the "Clear all caches" button
    • (expected) result: the performance settings page now has the "Caches cleared." notification
  • action: point browser back to ?q=admin/config/search/clean-urls
    • result: nope, did not work. the page still sports the (unchecked) checkbox and there's no "Run the clean URL test"
  • action: dumped DB with phpMyAdmin and diffed with previous dump
    • result: too many changes to give details, just noted that the cache_bootstrap table's row with cid='variables' is still there
My conclusions

I'm not sure what the logic is supposed to be, but there's definitively something inconsistent going on here.

I think that the ideal logic should depend on whether the code can or cannot automatically and reliably test for clean URL support without ending up displaying a 404.

If it's NOT possible to check reliably then IMHO the logic should be:

  • do NOT do the test on page load
  • always show the checkbox
  • always show the link/button to the test, with an explanation on how to come back if the test fails

If it's possible then IMHO loading this page can be (from the user's point of view) what is needed to perform the test and the logic should be:

  • do the test on page load
  • if server support is there, show the checkbox (with current setting) and clearly notify the user that server support is there
  • if server support is NOT there
    • if clean URLs generation is disabled, show the checkbox and clearly notify the user that server support is NOT there and enabling clean URLs may break the site (ideally also explain how to come back to this page if that actually happens)
    • if clean URLs generation is enabled, DISABLE clean URL generation, notify the user that it has been disabled, and then behave as if it had been disabled to begin with (or maybe even redirect to this same page)

Looking at the sources (and the comments there) it seems to me that the code is supposed to do the test iff the page is loaded from a non clean URL. But I always used the same URL (non clean) in my tests and yet the behavior did not revert when I reverted the server support. I'm a programmer but do not know PHP (and am totally unfamiliar with Drupal). Is it something with the "variables" and their caching that is going wrong? Too hard for me to dissect, but I guess someone more familiar with this code could figure it out.

geerlingguy’s picture

Major wtf from me - I noticed this problem on a shared host to which I had to manually upload the core files.

If you forget to upload the .htaccess file along with all the other configuration files, then the 'Enable clean URLs' checkbox will not appear on the Clean URLs configuration page. The 'Test for Clean URLs' button (whatever it says) appeared, and seemed to do something... but didn't show any results.

Once I uploaded that file, the checkbox appeared.

geerlingguy’s picture

Status: Active » Closed (duplicate)

Just noticed an older issue for the same problem: #881376: "Run the clean URL test" UX is broken. Please move discussion there.

cygii’s picture

Did you try uncomment RewriteBase / in .htaccess ? If your drupal site is inside subdirectory add RewriteBase /your-subdirectory-name
Works for me

theGuardian-1’s picture

If you are unsing apache:

in "httpd.conf" file try to locate this line for apache to have the ability to do whatever it wants from the root of your site to whatever under.
my root here is "c:/wamp/www/"

Directory "c:/wamp/www/"
...
AllowOverride all
...
/Directory

then you should aslo look for :

#LoadModule rewrite_module modules/mod_rewrite.so

and take off the '#' so apache has loaded the module for rewriting URLs

then, just restart your apache services. And finally reload your page.

normally you should see the check box.

hope i helped. And sorry for any english mistake, my mother tongue is french.

hcabbos’s picture

I banged my head on this for hours. Turns out my hosting company and perhaps many other people on shared hosts need their .htaccess file changed as follows:

This line needs uncommented:
RewriteBase /

***But more importantly,*** for Site5 hosting (and maybe yours too), you need to enter the hosting account user name as follows:
RewriteBase /~[username]/

bw1drup’s picture

I found this rewrite code on my hostmonster forum from Falcon1986 that fixed the problem for me.

According to the Drupal documentation, you should have the following mod_rewrite in your .htaccess file.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

vega’s picture

I was able to enable clean urls after uncommenting
RewriteBase /
in the .htaccess file. And then going to the clean urls URL, without the ?q=
When I did that, the option to enable was presented to me.

mudtraining’s picture

I couldn't get past the Clean URL test either... Took a while to track this down. #14 is the fix for me. http:///admin/config/search/clean-urls

flexiblemirror’s picture

Thanks, #13 works for me

MarkRennes’s picture

When I run the clean URLs test, nothing happens. The "Run the clean URL" button remains visible. What is presumably the command actually run is briefly displayed:

http://127.0.0.1/modules/Drupal/?q=admin/config/search/clean-urls&render...

Clean URLs can be seen subsequently NOT to have been set.

The contents of the .htaccess file that I believe to be relevant are:

RewriteBase /Drupal

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
#RewriteRule ^ index.php [L]
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

I am confident that this is at least one of the .htaccess files which are accessed. However, there are other .htaccess files in sub-directories of Drupal. The full list is:

.htaccess 53 bytes File 21/03/2003 07:16 -a--- home
.htaccess 792 bytes File 16/06/2011 21:27 ----- modules\Drupal\sites\all\libraries\ckeditor
.htaccess 118 bytes File 23/07/2011 08:42 -a--- phpmyadmin\setup\lib
.htaccess 118 bytes File 23/07/2011 08:42 -a--- phpmyadmin\libraries
.htaccess 118 bytes File 23/07/2011 08:42 -a--- phpmyadmin\setup\frames
.htaccess 93 bytes File dimanche 08:05 ra--- modules\Drupal\sites\default\files
.htaccess 107 bytes File dimanche 08:05 ra--- tmp
.htaccess 107 bytes File dimanche 08:09 ra--- modules\Drupal\sites\default\files\private
.htaccess 5,37 KB File Today 17:41 -a--- modules\Drupal
.htaccess.bak 5,38 KB Fichier BAK Today 17:25 -a--- modules\Drupal

Can anyone suggest what it is that I am doing wrong? Many thanks.

MarkRennes’s picture

Problem solved, at least for me! To do it, I have reinstalled Drupal, PHP, MySQL and Apache... via xampp.

I had been using EasyPHP. I have now uninstalled that, installed xampp, and started with a fresh database. I had kept details of all the content and admin changes I'd made in my various earlier attempts to start building my websites. Clean URLs worked immediately on creating a new site in localhost.

spyderpie’s picture

Uncommenting # Rewritebase / worked for me.

Vandalf’s picture

I had the same problem, and nothing I ever did worked. Whenever I tried to run the test, with whatever setting in .htaccess (my page is on a remote webhost, but I know that httpd has got the correct settings, as another site I've got is running perfectly with clean url's), I only returned to the test page, and nothing really happened.
Then, in a brighter moment, I tried to remove the ?q= from the url to the test, and all of a sudden I got a check-box giving the option to use clean url's!
Don't ask me why the test couldn't redirect me to the check-box page, but anyway, it now WORKS! :)

jagmeister’s picture

I am a noob to this. I am using hostmonster but nothing works and i dont know if i am editing correctly. my .htaccess file just has the apache handler then there is a .htaccess.txt file in which i see something like
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]

should i replace it with
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
or should i add it somewhere else

NEVER MIND
I got it to work by renaming the .htacess.txt file to .htaccess

kaba85’s picture

Version: 7.x-dev » 7.9
Category: bug » task

Removing # before the /RewriteBase solved the problem for me :)

fuse’s picture

I had the same problem, tried Vandalf's method in #20 en was able to enable clean URL's.

Maybe someone need to look into this problem, because this ahppend to me with a fresh install on a server I was previously able to switch on clean URL's without any problems on other Drupal installations. Maybe this bug got introduced since 7.9?

Edward.H’s picture

#20 worked for me ,I don't know why ,but I worked :)

drupalese4711’s picture

#20 worked for me, too.
Thanx a lot Vandalf, i wish you a merry christmas!!! :-)

drupalastic’s picture

FileSize
68.21 KB

For local wamp/apache users simple steps :

click wamp icon on tray

apache > apache modules

select rewrite_module (mark selected)

refresh and the test will pass

make sure to restore .htaccess to its default (if you have made any changes)

clean url test fails

diskojerk’s picture

I was unable to pass a clean urls test on my site while in maintenance mode. I took it out of maintenance mode and the checkbox to enable clean urls was there.

V7.12

tpg’s picture

I tried all of the above including 13 but in the end found a post which had the following

http://domain/admin/config/search/clean-urls

I did this and now my clean URL's are working.

Hope it helps.

sethviebrock’s picture

You can't get the clean URL test to pass while browsing in the admin overlay on a previously-non-clean-URL site. To reproduce this issue, you have to be running non-clean URLs, with admin overlay enabled, and run the clean URL test - it will fail. Either disable admin overlay or go directly to admin/config/search/clean-urls and run the test again. It should work and provide you with a checkbox to enable clean URLs if your .htaccess file is correct and mod_rewrite is enabled.

phuongnam3k’s picture

#11 works for me! Thanks so much. you're awesome

jaxx0rr’s picture

ye this worked for me (#11 and #26) but in .htaccess this line needs to be COMMENTED
# RewriteBase /

josephsergio’s picture

My .htaccess file only has the following:

SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
Options None
Options +FollowSymLinks

_ _ _ _ _

Does anyone have a solution as I still cannot enable clean URLS? Thanks in advance

Anonymous’s picture

Don't forget to get your site out of maintainance.
When it's in maintenance you can't enable clean url's

avonleadesign’s picture

I had to add hash to RewriteBase / so it became # RewriteBase /
and then follow #14! Thanks, Vega!

WriteCo’s picture

Uncomment RewriteBase and clear the cache. I worry me sometimes...

Oh right, I just updated to 7.16, fyi, and somehow I lost the working .htaccess file I had. ...All better now.

PEP3’s picture

I had the same problem the cure?

- Take the site out of maintenance mode......

Then it all suddenly worked. Is it perhaps worth adding that note to the clean urls test page as it could save lots of people hours of working out what is wrong?

mkapst’s picture

#13 worked for me

goback136’s picture

#36 worked for me.

Anonymous’s picture

NOTHING works for me! I have tried every single one of the above options and more.

kalidasan’s picture

(#26) Its working fine for me. Thanks dude. Cheers !.

I have enabled RewriteBase / from .htaccess But no use. It was not worked (I can able to see the check box. But could not save it).
After Enabled rewire_module from apache modules only it was working.

fullerja’s picture

#29 solved my issue. I am upgrading from a D6 site. It seems that there is some conflict between overlay and clean URLs. I disabled Overlay, enabled Clean URLs, and then re-enabled Overlay. All seems to work now, including Overlay. Order of operations is a little strange to me, but hey it works!

chitwarnie’s picture

Version: 7.9 » 7.22
Status: Closed (duplicate) » Fixed
Issue tags: +clean-urls, +drupal 7, +mod_rewrite, +XAMPP, +ubuntu 12.04 LTS
FileSize
5.28 KB

Environment

Ubuntu 12.04 LTS
XAMPP (apache 2.2, PHP 5.3)

for some reasons Drupal did not install the .htaccess even with my mod_rewrite enabled so i just copied from a previous installation and it started fine (my previous installation was Drupal 7.2) current version 7.22 has the issue we are discussion right now.

just copy the code from the attached file and paste it on a new file called .htaccess and save the changes and all should be ok

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

krknth’s picture

This link also will helps to disable clean URLs its worked for me
Disabling clean URLs

tmehta’s picture

@theGuardian - Very simple but effective to-the-point solution. Can't thank you enough!

sky10’s picture

Issue summary: View changes

Hi all,

I had this problem with wamp. The path of drupal was www/drupal. I solved this in 2 simple steps:

1. Uncomment this line in httpd.conf: LoadModule rewrite_module modules/mod_rewrite.so
2. Modified this line in .htaaccess: RewriteRule ^ drupal/index.php [L]

caco13’s picture

#14 worked for me, without to uncomment line

RewriteBase /

in .htaccess

The problem was just that the menu path to Clean Url enable/disable page writes the URL with ?q=, and then the box Enable clean URLs is not displayed. If I correct the URL (whitout ?q=), the bottom is displayed and I can select it. Now works fine.

Thanks vega!

mahipal46’s picture

#20 works for me... great ;)

miniwebs2’s picture

SOLVED: Drupal 7.39 Clean URL's fail on custom template installed. Tried all sorts of modifications until one of the comments above solved the problem.
Remove the ?q= from the url to the test and run again - checkbox now comes up and clean url's can be enabled.
Weird but worked for me!

randomyao22’s picture

If all above fixing are not working for you, you may need to have a look at two things:
1. Is your .htaccess working?
2. Is your mod_rewrite working?
See how to test and fix them: https://docs.bolt.cm/howto/making-sure-htaccess-works

SseggembeMoses’s picture

#8 worked for me