命令开启

sudo a2enmod rewrite

sudo /etc/init.d/apache2 restart

即可开启重写,不行的话再试下下面方法

ubuntu如何开启Rewrite模块

在终端输入:

sudo a2enmod rewrite  开启Rewrite模块(停用模块,使用 a2dismod)

sudo gedit /etc/apache2/sites-available/default 修改下面的地方

<Directory />

Options FollowSymLinks

AllowOverride None(修改为AllowOverride All)

</Directory>

<Directory "/var/orioner">

Options Indexes FollowSymLinks MultiViews

AllowOverride None(修改为AllowOverride All)

Order allow,deny

allow from all

</Directory>

最后sudo /etc/init.d/apache2 restart。

----------------------------------------------------

在网站下面建立.htaccess文件

修改.htaccess文件属性  chmod -R 777 .htaccess

Windows如何开启Rewrite模块

环境:

系统 Windows

Apache 2.2

加载Rewrite模块:

在conf目录下httpd.conf中找到

LoadModule rewrite_module modules/mod_rewrite.so

这句,去掉前边的注释符号“#”,或添加这句。

允许在任何目录中使用“.htaccess”文件,将“AllowOverride”改成“All”(默认为“None”):

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be “All”, “None”, or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

AllowOverride All

在Windows系统下不能直接建立“.htaccess”文件,可以在命令行下使用“echo a> .htaccess”建立,然后使用记事本编辑。

CentOs开启Apache的rewrite_module

centos的配置文件放在: /etc/httpd/conf/httpd.conf

打开文件找到:

LoadModule rewrite_module modules/mod_rewrite.so

将前面"#"去掉,如果不存在则添加上句。

如果你的网站是根目录的话:找到

 代码如下 复制代码

<Directory />

  Options FollowSymLinks

  AllowOverride None 

</Directory>

将上面的None改为All

如果你的站点不在根目录,设置如下:

 代码如下 复制代码

<Directory "/var/www/html/my_directory">

Order allow,deny

Allow from all

AllowOverride All

</Directory>

OK,然后重启服务器,service httpd restart ,这样.htaccess就可以使用了。

apache开启rewrite重写的更多相关文章

  1. 【转】CentOs中Apache开启rewrite模块详解

    rewrite是apache环境的一个伪静态功能了,如果我们没有没让Apache开启rewrite功能,网站上所有的rewrite规则都不可使用. centos的配置文件放在: /etc/httpd/ ...

  2. Ubuntu 中 apache 开启 rewrite 模块

    ubuntu14.04中安装好apache2.4之后默认rewrite模块是不开启的,项目public目录下的.htaccess文件就用不了,在浏览器中访问网页总是报500错误,原因就是这个. 执行下 ...

  3. CentOS下Apache开启Rewrite功能

    1.centos的配置文件放在: /etc/httpd/conf/httpd.conf 打开文件找到: LoadModule rewrite_module modules/mod_rewrite.so ...

  4. Apache开启Rewrite伪静态

    环境:Windows 2003 Apache 2.2 加载Rewrite模块 在conf目录下httpd.conf中找到 去掉# LoadModule rewrite_module modules/m ...

  5. centos7 Apache开启URL重写组件并配置.htaccess实现伪静态

    第一.修改httpd.conf文件 A - 在etc/httpd/conf/目录下的httpd.conf 文件,找到: LoadModule rewrite_module modules/mod_re ...

  6. Apache开启rewrite

    1.找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#号 2.找到AllowOverride None 改为:AllowOverride ...

  7. windows apache开启url rewrite

    加载Rewrite模块: 在conf目录下httpd.conf中找到 LoadModule rewrite_module modules/mod_rewrite.so 这句,去掉前边的注释符号“#”, ...

  8. apache开启重写模式

    现在的好多的框架都使用有路由机制,但是如果在apache下,没有开启重写模式,服务器不会读取路由 所以今天要分享一下apache开启重写模式 ubuntu下: 1.在命令行下 sudo a2enmod ...

  9. nginx 隐藏index.php 并开启rewrite日志调试(apache也有)

    开启rewrite 日志 error_log       /data/log/nginx/error.log notice; 位于最外层,大约在文件的前几行 再在http{}括号里增加一行:rewri ...

随机推荐

  1. [LintCode] Copy Books 复印书籍

    Given an array A of integer with size of n( means n books and number of pages of each book) and k pe ...

  2. VMwareTools 安装(VMware Player)

    1. VMare Tools 按钮是灰化的,需要对虚拟机做如下设置:(在虚拟机没有启动的状态下进行)     1)Player(P)->管理->虚拟机设置->CD/DVD  选择:使 ...

  3. Linux_初识

    一.什么是 Linux  ♦ 试说明 Unix 与 Linux 的历史 Multics 系统:由Bell(贝尔实验室).MIT(麻省理工学院)与GE(美国通用电器)合作开发的一个系统: 1969:K. ...

  4. spring框架和junit框架结合使用案例

    package ltssh; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.be ...

  5. 日历js插件

    因为做了一个培训管理模块,要有一个开始与结束培训时间.时间日期如果个用户手动输入的话,即使你要求了时间格式,但是用户可能还是会输错时间格式.所以想想,还是找了一个js日历插件.下面来介绍下我自己用的一 ...

  6. cocos2d-x渲染流程

    Cocos2Dx之渲染流程 发表于8个月前(2014-08-08 22:46)   阅读(3762) | 评论(2) 17人收藏此文章, 我要收藏 赞2 如何快速提高你的薪资?-实力拍“跳槽吧兄弟”梦 ...

  7. 括号配对nyoj2(疑问)

    描述现在,有一行括号序列,请你检查这行括号是否配对.   输入 第一行输入一个数N(0<N<=100),表示有N组测试数据.后面的N行输入多组输入数据,每组输入数据都是一个字符串S(S的长 ...

  8. include文件时尽量使用绝对路径

    1.如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍. 2.$row['id'] 的速度是$row[id]的7倍. 3.echo 比 print 快,并且使用ech ...

  9. Unity学习疑问记录之正交与透视

    Unity中相机的投影是2种方式,正交和透视 这是透视方式 正交方式: //计算屏幕宽度 float height = 2.0f * Camera.main.orthographicSize;//正交 ...

  10. Cookie案例-显示商品浏览历史纪录

    package cn.itcast.cookie; import java.io.IOException; import java.io.PrintWriter; import java.util.D ...