歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> Linux業界 >> Ubuntu系統啟用Apache Mod_rewrite模塊

Ubuntu系統啟用Apache Mod_rewrite模塊

日期:2017/3/2 13:46:19   编辑:Linux業界

  在終端中執行

  sudo a2enmod rewrite

  指令後,即啟用了 Mod_rewrite 模塊。

  另外,也可以通過將 /etc/apache2/mods-available/rewrite.load 連接到 /etc/apache2/mods-enabled/rewrite.load 來打開 Mod_rewrite 模塊。用指令操作就是:

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

  一點小提示

  事實上,當我在 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:

  sudo /etc/init.d/apache2 restart.

Copyright © Linux教程網 All Rights Reserved