Debian/Ubuntu Apache Mod_Rewrite 安装

在终端中执行,我常常是使用putty 来远程连接的,这样省的在2个操作界面切换。

#debian
a2enmod rewrite
#ubuntu
sudo a2enmod rewrite

指令后,即启用了 Mod_rewrite 模块。

另外,也可以通过将 /etc/apache2/mods-available/rewrite.load 连接到 /etc/apache2/mods-enabled/rewrite.load 来打开 Mod_rewrite 模块。用指令操作就是:

#debian
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
#ubuntu
sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

一点小提示

事实上,当在Debian or Ubuntu 中采用上述做法并重启了 Apache 服务后,仍然无法正常 rewrite 网址。这里,还有一点需要注意的地方:

sudo vim /etc/apache2/sites-enabled/000-default

将其中的:

AllowOverride None

修改为:

AllowOverride All

上面的 /etc/apache2/sites-enabled/000-default 实则为 /etc/apache2/sites-available/default 的连接。而 AllowwOverride None 则会完全忽略 .htaccess 文件,自然其中所定义的 rewrite 规则也就不能生效了。

最后,别忘了使用下列指令来重启 Apache:

#debian
/etc/init.d/apache2 restart
#ubuntu
sudo /etc/init.d/apache2 restart

Related posts:

  1. Ubuntu Server apt-get install Apache2 & PHP5 & MySQL5
  2. ubuntu server 8 上建立虚拟主机 和 目录文件夹实现用户验证
  3. Ubuntu Server Network Configuration
  4. Windows 下 Apache Virtualhost 设置
  5. Linux(debian&ubuntu)下./configure错误详解
此条目发表在 Linux-Server 分类目录,贴了 , , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word