12

我刚刚安装并开始使用 Drupal 7,并按照说明打开了 Clean Urls。我单击了“运行 Clean URL 测试”按钮,但没有返回任何结果。它加载一些东西,然后刷新页面。

谁能阐明为什么会这样以及我能做什么?

4

7 回答 7

21

有时以某种方式打开已清理的 URL 页面会失败并且不会显示错误(从系统的角度来看,我猜没有错误)。尝试手动更改 URL:

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

到:

www.mydomain.com/admin/config/search/clean-urls

并查看它是否显示复选框,是否显示,选择它并保存。

于 2011-08-05T16:18:16.857 回答
10

创建文件 phpinfo.php,内容:<?php phpinfo();?>然后通过浏览器加载它。查找文本“加载模块”,它应该包含“mod_rewrite”。如果不是,请在您的 apache 配置中启用它(您可能会问如何启用)。

于 2011-07-18T09:06:35.987 回答
6
于 2012-01-22T16:30:19.430 回答
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.

于 2012-10-27T17:32:07.257 回答
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
于 2012-10-11T05:22:44.430 回答
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.

于 2012-09-21T13:14:56.430 回答
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.

于 2012-10-10T19:16:17.090 回答