命令开启

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. thinkphp类的调用

    1.在controller下新建一个类,类的名称必须按照tp的规范来写. 2.在需要调用的类中,只需new一下被调用的类名. $t=new DataController(); $t->m();

  2. ThinkPHP留后门技巧

    原文链接:https://www.leavesongs.com/PENETRATION/thinkphp-callback-backdoor.html 90sec上有人问,我说了还有小白不会用.去年我 ...

  3. c#中文转全拼或首拼

    参考:http://www.jb51.net/article/42217.htmhttp://blog.csdn.net/cstester/article/details/4758172 Chines ...

  4. SSH环境 jsp url跳转,带中文参数乱码问题

    URL中编码格式为ISO-8859-1,处理中文只需将编码格式转换ISO-8859-1 方法一: http://xxx.do?ptname='我是中国人' String strPtname = req ...

  5. jquery 绑定事件的方法

    jQuery中提供了四种绑定事件的方法,分别是bind.live.delegate.on,对应的解除监听的函数分别是unbind.die.undelegate.off: 一.on()方法(首选方法) ...

  6. Android动画设计源码地址

    Android动画设计源码地址 http://blog.csdn.net/shanghaibao123/article/details/45223825

  7. golang protobuf SetExtension

    对golang protobuf 的扩展字段赋值时候一直提示proto: bad extension value type clkUrl:="z.cn" proto.SetExte ...

  8. autocomplete一次返回多个值,并且选定后填到不同的Textbox中

    $(txtTest1).autocomplete({ source: function (request, response) { $.ajax({ url: 'HttpHandler.ashx?to ...

  9. LeetCode Best Time to Buy and Sell Stock with Cooldown

    原题链接在这里:https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/ 题目: Say you hav ...

  10. 个人对AutoResetEvent和ManualResetEvent的理解(转载)

    仅个人见解,不对之处请指正,谢谢. 一.作用 AutoResetEvent和ManualResetEvent可用于控制线程暂停或继续,拥有重要的三个方法:WaitOne.Set和Reset. 这三个方 ...