Here are some of the most common reasons why your clean URLs may not be working (assuming you're using a normal Linux/Apache hosting environment).

1. Your site is in a subdirectory, or you're using an Alias, but you didn't set RewriteBase #

If your site URL looks like this:

http://example.com/~jsmith1/drupal/

Then you need to set RewriteBase! Find the section in your .htaccess file that looks like this:

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

And change the last line, like this:

  RewriteBase /~jsmith1/drupal

Make sure you remove the # symbol in front of RewriteBase, otherwise this will not work.

If you move your site later on, this line will need to be changed again. For example, if you later move it to: http://your-site-here.com/ then update the line to RewriteBase / (or just comment it out with a # in front).

VARIANT. When using an Alias, if your site URL looks like this:

http://example.com/YourAliasName/

Then you must change the last line as stated above, like this:

  RewriteBase /YourAliasName

2. Your .htaccess file didn't get uploaded at all. #

Check if the .htaccess file was actually uploaded. It should be in the directory where you uploaded Drupal (for example: /public_html/drupal/)

If the .htaccess file is missing, you need to upload it. If you accidentally deleted this file, just download Drupal again, and copy the new .htaccess file.

Make sure the file is only called .htaccess and not htaccess.txt or anything else. The .period .at .the .beginning is required.
This name usually means that the file will be invisible on folder listings on Unix-based systems so you might not always see it. If using an FTP client, you may have to configure it to 'show hidden files'. If listing on the commandline, you must ls -la to see it. This will be somewhat dependent on your OS.

3. Your .htaccess file is corrupt. #

The .htaccess file is very fussy, and only works if things are in a certain order. If you've tried to add password protection or to block image hotlinking (especially if you used cPanel or some other software to set that up), you've probably corrupted the file. The simple solution is to delete your corrupted .htaccess file, then upload the standard version that comes with Drupal.
Evidence of a broken htaccess file can usually be seen in the Apache logs. If you have access on the host, the logs may be at /var/log/apache2/error.log or some variation like that. If you are on a shared host, see your ISPs documentation or helpdesk.

4. Pager and other query strings don't work #

Make sure you have not modified the Apache rewrite rule. The default RewriteRule is:

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

What this rule does is rewrite a path like example.com/node into example.com/index.php?q=node

However, you'd normally then expect that path like example.com/node?page=1 would be re-written into example.com/index.php?q=node?page=1 which would fail since both separators are ?.

However, the rewrite rule has additional flags. The 'L' flag is irrelevant, but 'QSA' makes the difference. What it does is to preserve any existing arguments after the rewrite, thereby changing the second '?' in this scenario into '&'.

Comments

mattstevenson2’s picture

It seems like there should be a way for Drupal to check a user's server to make sure that the .htaccess file even exists. If it's missing (as mentioned in reason #2 above) then I'm sure some more novice users would benefit from a message stating that it doesn't exist, and then point them to this page. Right now it's very cryptic when you run the Clean URLs test in D7 with no htaccess file...it does nothing but reload the page when you click run test and doesn't provide any message why.

TanvirAhmad’s picture

Sometimes somehow the opening up of the cleaned URL page fails and does not display an error (as I guess from the perspective of the system there is none). Try to manually change the URL from:

www.mydomain.com/?q=admin/config/search/clean-urls
to:
www.mydomain.com/admin/config/search/clean-urls

And see if it displays the checkbox, of it does, select it and save.

t@n

Draven_Caine’s picture

It worked for me, I turned off clean url's and than it said the test fail even though it was off for about 5 minutes.
So i did what you said and it worked wonders. thanks for documenting your solution.

GregariousJB’s picture

This just saved my ass. Thank you. Fuckin' Clean URLs. Not touching that again.

robbielink’s picture

This solved my problem. I had been using clean URLs all along but read that when migrating a site I should turn them off before downloading the site for migration. When I turned them off and ...../admin changed to ...../?q=admin the clean URLs page said "clean URLs can not be enabled and the checkbox was gone. After downloading the site for migrating I wanted to turn them back on (on the old site, still) and your suggestion worked. I took the ?q= out of the URL and suddenly the checkbox to enable them is back.
Thanks!

tugis’s picture

To have clean urls working, also make sure that in the settings of your apache (if you are using apache, /etc/apache2/sites-available/default for example), you have:

AllowOverride All

so mod_rewrite can do its job.

JLambrecht’s picture

Thank you very much, this was part of the WSOD remedy.

In case someone ends up here check http://drupal.org/node/158043#comment-5300544 for a possible/partial solution to your problem.

rickumali’s picture

For me to realize it was my AllowOverride, I did and saw this at the command line:

# cd /etc/apache2/sites-enabled
# grep -i allowoverride siteinquestion
                AllowOverride None
                AllowOverride None

I couldn't believe I had it set to None!

One other tip: From the Apache2 tutorial on .htaccess files: "A good test for this is to put garbage in your .htaccess file and reload. If a server error is not generated, then you almost certainly have AllowOverride None in effect."

pierredvumali’s picture

I'm having problems with my site. I don't know where to set the allowoverride in the httpd.conf file. and I can't execute the command the type in the command line because I don't have a apache2 folder but I'm using apache. If you could guide me through the process it will be deeply appreciated.

pierredvumali’s picture

-I just ensured that mod_rewrite is enabled
-Replaced all instances of "AllowOverride None" to "AllowOrride All" in my apache.conf file, in my case it is httpd.conf
-Uncomment the "RewriteBase /" in .htaccess
-Restart apache by apachectl restart through the command line, in my case ssh
-Then the clean urls are accepted and I can access my site properly

johnpk’s picture

you've saved lots of time

lalitanand’s picture

was facing same issue! got resolved after making the change in sites-available/default

ishwar’s picture

Great .... It is working for me

Wolf_22’s picture

I know most of you probably realize this, but particular emphasis needs to be placed on Apache's mod_rewrite module. I use WAMP a lot for my development and unless you have it enabled through the httpd.conf file, your links will constantly return you to your WAMP root location upon being clicked on. To solve this, just go edit your httpd.conf file by left-clicking on the little WAMP icon, hover over the "Apache" menu item, then click on "httpd.conf". Then find the following line inside the text editor that comes up:
#LoadModule rewrite_module modules/mod_rewrite.so

Simply remove that pound sign ('#') and save. Restart WAMP and you're golden. :.)

Hope this helps someone in the future.

grabo’s picture

Uncomment /Rewritebase in htaccess file, uninstall overlay module (not only disable) and then activate clean urls.

monstordh’s picture

I had tried EVERYTHING, but this worked!!! THANK YOU!!!

samsterlin’s picture

This trick is working to me.

fahey252’s picture

I was in maintenance mode when trying to enable Clean URLs. The clean URL test kept failing. Once I took the site out of maintenance mode, I was able to successfully enable clean URLs.

mrcniceguy’s picture

Thanks alot this worked for me too))

Aliyah Deeva’s picture

Thanx.

egarias’s picture

After trying everything it worked!

Egarias
Turning opportunities into business

vivdrupal’s picture

taking the site off maintenance mode did the trick for me. thanks again for posting.

Aliyah Deeva’s picture

If you're in maintenance mode it will not work. Get out of maint. mode and then enable clear URLS. Thanks to someone above me who said it first.

salytwo’s picture

I uploaded my website in the my hosting account and the .htaccess is existed but not working

songagna’s picture

Thanks a lot for that solution. I spent too much time to that problem and i just fix it now :)

reakinghavoc’s picture

Clean URLs just won't work. I tried many conbinations of uncommenting RewriteBase. I tried RewriteBase /, Rewitebase /~username, RewriteBase /mywebsite and many more! I wasted hours doing trial and error.

My host is Bluehost and I'm using Drupal 7 btw.

cparecki’s picture

I am using Bluehost and Drupal 7 too!

TransientJay’s picture

Hi all,

not working for me I'm afraid!

Initially, the module told me the test had failed.
So, I then changed RewriteBase to RewriteBase /DrupalSite as my site is located in htdocs/DrupalSite.

The module then allowed me to check the tick box. The clean urls worked in the admin area but not the main site.

I added some meaningless characters to my .htdocs file to see if the it is the Allowoveride fix but the site crashed as expected.

Any ideas? It seems like nothing will work for me... I'm being hosted on Network Solutions if that helps

Thanks for any help!

mabho’s picture

You can disable clear URLs by adding the following line to your settings.php file:

$GLOBALS['conf']['clean_url'] = 0;

For some reason, a brand new project I was taking had this line of code and clean URLs wouldn't take over, although I had already set it in config. Since the settings.php file has priority over the Drupal configuration set in admin, clean URLs weren't kicking in.

cazam’s picture

I had the same problem, for some reason a fresh install of drupal 7 had this set on the settings.php. Every time I enabled clean URL it said the settings were saved but the box would be unticked again.
Not sure if it's relevant, but the server in question is a plesk based and drupal was installed directly within plesk.

nattyweb’s picture

My symptoms were that the Clean urls checkbox on admin/config/search/clean-urls was showing empty, even though I checked it on; return to that page and it showed empty again. Clean URLs were working in that I could remove the ?q= from the url in the address bar of the browser and that would take me to the correct page. However, all internal Drupal urls reverted to showing the ?q= again.

Edited the line at the end of settings.php from $GLOBALS['conf']['clean_url'] = 0; to $GLOBALS['conf']['clean_url'] = 1; and the Clean urls checkbox now shows 'checked' correctly.

Now everything is working fine. Thank you so much mabho and cazam - I have spent hours trawling for a solution that would work for me.

krazykellie’s picture

THIS WORKED! THANK YOU!!!

muddie’s picture

Was searching for ages and this worked. That's the last time I use the one click install for Drupal on my server if it's going to be putting stuff like that in the settings file.

wdseelig’s picture

Thank you very much for this post. It got rid of the problem immediately.

Wyckham

V80224’s picture

resolved!

theargument’s picture

Hoping that someone can help me out. I have a dedicated server running ISPConfig to manage the domains. I'm in the process of moving sites over from another identical server following a Drupageddon issue. I have about 20 Drupal 7.32 sites to move (joy).

The odd thing is that for site number 1 - clean URLs works fine. But for site number 2 - no matter what I do I can't get it to work. I know mod_rewrite is on (it must be!) - and I've duplicated the .httaccess file for site 1 in site 2 - with Rewritebase / - uncommented (in both). They are both D7.32 installs with similar configs.

I've checked the default apache2 settings and the .vhost settings for both sites and Allowoverride is set to all for the web root directory in both cases. So - does anyone have any idea why one site would be fine and the other not?

aneebayon’s picture

I have faced problem with "Access Denied" issues and find many solution in google but didn't get perfect solution.
But In this post I have got best solution and my problem solved now. It really helpful to me. Thanks..... :)

nourheine’s picture

Hi i have the same issue except this is with %3C that is equal to < , my htaccess not really interpreting this in my URL if i have this gfhjh< hghf>jkjh,i got this gfhjhjkjh so what to do ?

Abbass’s picture

To check if your APACHE rewrite module is checked on https://www.drupal.org/node/1114770#comment-11737454

gourav.yadav’s picture

it's working

bamest4christ@gmail.com’s picture

I am having serious challenge in having a clean url. Pleasee guys what do i do, i have try all i can but to no avail. I am on shared hosting and can't have access to httpd file.