Clean urls not working in Drupal 7 [closed]
Asked Answered
L

7

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?

Lanta answered 17/7, 2011 at 20:4 Comment(2)
Open your .htaccess file in your project root. Uncomment RewriteBase /drupal and change it to your project name like RewriteBase /myprojectname Comment RewriteBase /Microbalance
# If your site is running in a VirtualDocumentRoot at example.com, # uncomment the following line: RewriteBase / godady I did like -> it worksSchrader
C
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).

Chiba answered 18/7, 2011 at 9:6 Comment(4)
It was already enabled. Is there a way of setting up clean urls another way? This button is clearly not working for me.Lanta
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.Lanta
Ok, solved it by modifying the httpd.conf file. This page was very helpful to me: drupal.org/getting-started/clean-urlsLanta
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.Peay
O
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.

Osmond answered 5/8, 2011 at 16:18 Comment(4)
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.Nabila
Wow. I wish I read this before wasting 3+ hours. Thank you artonice!Briannabrianne
Was having this exact problem.Flown
My first thought was, that's never going to work! and then....yup, it worked.Consultative
C
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).

Chiba answered 18/7, 2011 at 9:6 Comment(4)
It was already enabled. Is there a way of setting up clean urls another way? This button is clearly not working for me.Lanta
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.Lanta
Ok, solved it by modifying the httpd.conf file. This page was very helpful to me: drupal.org/getting-started/clean-urlsLanta
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.Peay
E
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
Epidemiology answered 22/1, 2012 at 16:30 Comment(0)
L
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.

Lashelllasher answered 27/10, 2012 at 17:32 Comment(1)
My .htaccess is quite similar: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]Polyhedron
S
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
Sacrum answered 11/10, 2012 at 5:22 Comment(0)
G
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.

Giule answered 21/9, 2012 at 13:14 Comment(0)
R
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.

Rephrase answered 10/10, 2012 at 19:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.