Ubuntu系统启用Apache Mod_rewrite模块
2016-05-20 10:22
603 查看
在终端中执行
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 规则也就不能生效了。
也就是
<Directory /var/www/wechatplugin/web/>
AllowOverride All
Options Indexes FollowSymLinks
</Directory>
最后,别忘了使用下列指令来重启 Apache:
sudo /etc/init.d/apache2 restart.
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 规则也就不能生效了。
也就是
<Directory /var/www/wechatplugin/web/>
AllowOverride All
Options Indexes FollowSymLinks
</Directory>
最后,别忘了使用下列指令来重启 Apache:
sudo /etc/init.d/apache2 restart.
相关文章推荐
- Apache Maven 入门篇(下)
- Apache Maven 入门篇 ( 上 )
- 源码编译安装apache
- centos下apache源码编译安装
- apache调优
- Apache Atlas安装文档
- apache常用的两种工作模式 prefork和worker
- Apache通过rewrite限制某个目录
- Apache禁止解析php
- Apache 禁止指定user_agent(防止爬虫扒取)
- Apache访问控制
- Apache配置防盗链
- Apache配置静态缓存
- Apache Oozie - the workflow scheduler for hadoop
- CoreException: Could not calculate build plan: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved
- Apache2.4和Apache2.2访问控制配置语法对比
- apache日志切割
- Apache不记录制定文件类型日志
- Apache配置域名301跳转
- Apache的Thrift引发的编译思考