如何在 ubuntu 上的 LAMP 中启用 mod_rewrite?

How to enable mod_rewrite in LAMP on ubuntu?(如何在 ubuntu 上的 LAMP 中启用 mod_rewrite?)
本文介绍了如何在 ubuntu 上的 LAMP 中启用 mod_rewrite?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我在我的机器上使用 Ubuntu 12.04 LTS linux.我已经在上面安装了 LAMP.现在我想启用 mod_rewrite 模块.我做了很多谷歌并尝试了很多技巧,但无法启用 mod_rewrite.谁能帮我启用 mod_rewrite?提前致谢.

I'm using Ubuntu 12.04 LTS linux on my machine. I've already installed LAMP on it. Now I want to enable the mod_rewrite module. I did google a lot and tried lots of tricks but couldn't be able to enable mod_rewrite. Can anyone help me to enable the mod_rewrite? Thanks in advance.

推荐答案

TL;DR version -- 在你的终端中执行以下操作:

TL;DR version -- do the following in your terminal:

sudo a2enmod rewrite && sudo service apache2 restart

有解释——在你的终端中执行以下操作:

With explanations -- do the following in your terminal:

ls -l /etc/apache2/mods-available/rewrite.load    ///if it prints out rewrite.load, it's there and ready to go

sudo a2enmod rewrite   //enables the mod

ls -l /etc/apache2/mods-enabled/rewrite.load // shows created symlink

sudo vi /etc/apache2/sites-available/default   //opens the file in vi (you can also use vim or nano)

根据需要将出现的AllowOverride None"替换为AllowOverride all"

Replace occurrences of "AllowOverride None" with "AllowOverride all" as necessary

sudo service apache2 restart    ///restarts apache

在/etc/apache2/sites-available 中编辑您的虚拟主机条目并将 AllowOverride All 添加到 DocumentRoot.您的虚拟主机最终应如下所示:

Edit your virtual host entry in /etc/apache2/sites-available and add AllowOverride All to the DocumentRoot. Your virtual host should ultimately look something like this:

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /var/www/vhosts/example.com
  <Directory /var/www/vhosts/example.com>
    AllowOverride all
  </Directory>
</VirtualHost>

虽然这不适合生产环境,但它适用于本地开发.

Although this isn't suitable for production environments, it works just fine for local development.

这篇关于如何在 ubuntu 上的 LAMP 中启用 mod_rewrite?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)