drupal 开启简洁链接

环境:ubuntu 10.04 ,apache2

 

简洁链接(clean urls)功能需要Enable mod_rewrite for Apache的,首先检查apache是否安装并启动了mod_rewrite,在终端中运行:apache2ctl -M  ,对ubuntu默认是启用的。对Debian 默认是关闭的。启用方法如下:

1. 激活mod rewrite,在终端中运行:a2enmod rewrite

 

2. 到 /etc/apache2/sites-available目录下执行sudo gedit default,修改如下:

 

(这里把所有的AllowOverride都由none改成all)

 

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

 

3. 最后到/var/www/drupal 下执行 sudo gedit .htaccess

  (找到如下一行并去掉注释)

 

 写道
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
 

 

4. 最后,重启apache:

 

 

因为重启apache一直报80端口被占用,所以首先控制台 sudo killall -9 apache2 除掉所有的apache进程

再执行 sudo /etc/init.d/apache2 -k restart



 

你可能感兴趣的:(apache,PHP,Debian,ubuntu,Blog)