12

I just installed and started using Drupal 7, and I followed the instructions to turn on Clean Urls. I clicked "Run the Clean URL test" button, but it failed to return any results. It loads up something and then refreshes the page.

Can anyone shed light on why this is happening and what I can do?

picardo
  • 24,530
  • 33
  • 104
  • 151
  • 1
    Open your .htaccess file in your project root. Uncomment RewriteBase /drupal and change it to your project name like RewriteBase /myprojectname Comment RewriteBase / – abhilashv Jul 02 '13 at 08:21
  • # If your site is running in a VirtualDocumentRoot at http://example.com/, # uncomment the following line: RewriteBase / godady I did like -> it works – tree em Aug 27 '13 at 12:26

7 Answers7

21

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.

m4rinos
  • 458
  • 4
  • 9
  • Thanks for that, that fixed it for me on a clean Ubuntu 12.04 LTS beta. I had everything setup correctly, mod_rewrite, the allowoverride, but still the Drupal test fails. I guess it's just a bug in Drupal because when you use that url and enable it, everything just works. – Karel Mar 19 '12 at 22:00
  • Wow. I wish I read this before wasting 3+ hours. Thank you artonice! – SomethingBetter May 07 '12 at 09:47
  • Was having this exact problem. – LoneWolfPR Oct 17 '12 at 16:06
  • My first thought was, that's never going to work! and then....yup, it worked. – Jukebox Jan 18 '15 at 03:40
10

Create file phpinfo.php, contents: <?php phpinfo();?> Then load it through your browser. Find text 'Loaded Modules', it should contain 'mod_rewrite'. If no, enable it in your apache configuration (you may ask how if so).

Alex Smirnoff
  • 478
  • 4
  • 10
  • It was already enabled. Is there a way of setting up clean urls another way? This button is clearly not working for me. – picardo Jul 19 '11 at 01:37
  • Oh by the way, my drupal install lives in a subfolder of the server, so not root. I know this was an issue in Drupal 6, but I don't know if it still matters in Drupal 7. – picardo Jul 19 '11 at 01:49
  • 1
    Ok, solved it by modifying the httpd.conf file. This page was very helpful to me: http://drupal.org/getting-started/clean-urls – picardo Jul 19 '11 at 02:32
  • I read that page and found my problem was needing "AllowOverride All" in my Apache virtualhost configuration, which allowed the stock Drupal .htaccess to work, which in turn permitted enabling clean URLs. – spiffytech Aug 25 '12 at 18:01
6

your apache config file (/etc/apache2/apache2.conf) must have the following 2 lines in it. If not then add them. This tells apache to look for a .htaccess file for settings in the folder “/var/www/drupal”

<Directory /var/www/drupal>
  AllowOverride All
</Directory>
AccessFileName .htaccess
Aliaksei Kliuchnikau
  • 13,589
  • 4
  • 59
  • 72
Kshitiz Singh
  • 61
  • 1
  • 1
5

My drupal7 install is on my pc with Ubuntu 12.04, in the folder usr/share/drupal7. The way I solved the problem was the following change in .htaccess in my drupal7 folder:

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

and add:

RewriteBase /drupal7

do not add RewriteBase /drupal.

Now the test is ok and all works well.

  • My .htaccess is quite similar: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] – shasi kanth Jul 03 '13 at 04:13
4

You have to enable mod_rewrite in apache to make clean urls to work

if mod_rewrite is not in phpinfo you have to install it by

sudo a2enmod rewrite

sudo apache2ctl -l

You need to replace the occurrence of AllowOverride none to AllowOverride all

and change like this

<VirtualHost *:80>
ServerAdmin admin@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

and Restart apache

sudo service apache2 restart
Akhilraj N S
  • 9,049
  • 5
  • 36
  • 42
2

I was having issues after a fresh install Drupal 7.15 on GoDaddy. I had to make the following change to .htaccess in order to get them working...

# 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] #GoDaddy Hosting

After that, the Clean Url Test still fails, but Clean Urls actually works as referenced in the answer by artonice.

Eddie
  • 5,050
  • 8
  • 37
  • 46
1

I also had that problem at a GoDaddy hosting, but the solution actually proved rather simple.

After uncommenting the following line in .htaccess, the clean URL test passed as expected:

# RewriteBase /

Please note, that my site is running at a domain root.

Scott
  • 21,211
  • 8
  • 65
  • 72
Zsolt Balla
  • 533
  • 2
  • 7
  • 16