The clean URL test failed in drupal 7

2019-07-21 08:11发布

问题:

The clean URL test failed. It was working correctly on my local computer, when I uploaded it to server I got this message and I could not enable the clean url. What should I do to enable it? I have uploaded the htaccess also.

回答1:

There are a number of requirements you'll need to confirm are met on the server. After confirming Apache is allowing your local .htaccess configuration override (as per Ayesh's comment) I'd start by checking info.php to see if mod_rewrite is loaded.

Make sure you remove info.php when you're done checking as you should not have this on a production server.



回答2:

have a look at Configure clean URLs, suppose you are using apache2

  1. enabled mod-rewrite in apache

    sudo a2enmod rewrite

  2. vi /etc/apache2/sites-enabled/000-default, change AllowOverride from None to All

<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all
</Directory>
  1. vi httpd.conf, add this
<Directory /var/www/>
      RewriteEngine on
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</Directory>

2. restart apache

sudo service apache2 restart


回答3:

If your entire site is password protected (via cpanel/.htaccess) Then the test will not pass. This may not be the solution but is worth checking.

I disabled password protection by commenting out the following lines in my .htaccess file.

AuthType Basic
AuthName "public_html"
AuthUserFile "/home/********/.htpasswds/public_html/passwd"
require valid-user

Run the test again, if it passes, tick the box then be sure to uncomment the previously commented lines.