• apache开启rewrite重写


    命令开启

    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就可以使用了。

  • 相关阅读:
    ASP.NET MVC5 :Attribute路由使用详解
    C# 常用字符串加密解密方法
    C#获取当前主机硬件信息
    用C#调用Windows API向指定窗口发送按键消息
    Win32 编程消息常量(C#)
    C#程序员开发WinForm必须知道的 Window 消息大全
    C#通过SendMessage发送消息,改变其他程序的下拉框控件(ComboBox)的值
    C#常用 API函数大全
    SendKeys发送组合键
    webapi get请求 FromUri list参数传递
  • 原文地址:https://www.cnblogs.com/li-mei/p/5959217.html
Copyright © 2020-2023  润新知