我刚刚安装并开始使用 Drupal 7,并按照说明打开了 Clean Urls。我单击了“运行 Clean URL 测试”按钮,但没有返回任何结果。它加载一些东西,然后刷新页面。
谁能阐明为什么会这样以及我能做什么?
我刚刚安装并开始使用 Drupal 7,并按照说明打开了 Clean Urls。我单击了“运行 Clean URL 测试”按钮,但没有返回任何结果。它加载一些东西,然后刷新页面。
谁能阐明为什么会这样以及我能做什么?
有时以某种方式打开已清理的 URL 页面会失败并且不会显示错误(从系统的角度来看,我猜没有错误)。尝试手动更改 URL:
www.mydomain.com/?q=admin/config/search/clean-urls
到:
www.mydomain.com/admin/config/search/clean-urls
并查看它是否显示复选框,是否显示,选择它并保存。
创建文件 phpinfo.php,内容:<?php phpinfo();?>
然后通过浏览器加载它。查找文本“加载模块”,它应该包含“mod_rewrite”。如果不是,请在您的 apache 配置中启用它(您可能会问如何启用)。
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.
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
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.
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.