如何在Ubuntu下啟動Apache的Rewrite功能

來源:互聯網
上載者:User

在終端中執行

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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.