开发者社区> 问答> 正文

云服务器 ECS Linux 下 Apache 忽略网站 URL 的大小写的方法

Linux 服务器访问路径都是区分大小写的,那么搭建了 Apache 后访问 www.abc.com/Index.html 和 www.abc.com/index.html 访问的路径是不一样的,如下图所示,实际首页是 Index.html:

展开
收起
开发者说 2019-07-15 09:20:41 523 0
1 条回答
写回答
取消 提交回答
  • 处理办法

    要解决这个问题,需要使用使用 Apache 的 mod_speling 模块。

    注意:启动了 CheckSpelling 可能会降低 Apache 的执行效率。

    全新编译安装 Apache

    编译安装 Apache 时把 mod_speling 模块也编译了,如

    ./configure --prefix=/usr/local/apache2 --enable-so --enable-speling

    修改 Apache 的配置文件 httpd.conf,加上:

    LoadModule speling_module     modules/mod_speling.so
    CheckSpelling On

     这样就启用了 mod_speling 模块。

     

    只编译安装 mod_speling 模块

    假设 Apache 安装目录是 /usr/local/apache2。

    1. 确认 /usr/local/apache2/modules 目录下存在 mod_speling.so 模块。
    1. 编译 mod_speling.so 模块, 进入 Apache 源码的 modules/mappers/ 目录,运行如下命令自动编译、安装和修改 httpd.conf 文件,激活 mod_speling.so 模块:
      /usr/local/apache2/bin/apxs -c -i -a mod_speling.c
    • -c 执行编译操作。
    • -i  安装操作,安装一个或多个动态共享对象到服务器的 modules 目录。
    • -a 自动增加一个 LoadModule 行到 httpd.conf 文件,以激活此模块,若此行存在则启用之。
    • -A 与 -a 类似,但是它增加的 LoadModule 行前有井号前缀(#)。
    • -e 需要执行编辑操作,可与 -a 和 -A 选项配合使用,与 -i 操作类似,修改 httpd.conf 文件,但并不安装此模块。

        apxs 命令选项说明

       3.  在 /usr/local/apache2/conf/httpd.conf 中添加:

    LoadModule speling_module     modules/mod_speling.so
    CheckSpelling On

       4.  重启 Apache:

    /usr/local/apache2/bin/apachectl restart 或 service httpd restart

    2019-07-15 09:21:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
如何运维千台以上游戏云服务器 立即下载
网站/服务器取证 实践与挑战 立即下载
ECS计算与存储分离架构实践 立即下载