duanhuiqing9528 2015-02-24 04:49
浏览 46

如何使apache托管网站url请求不区分大小写

I have my page1.php file located inside

/public_html/mypages/page1.php

if user requests www.myurl.com/Mypages/Page1.php is returning file not found

how can I ensure that each each request is handled irrespective of the case

I am using godaddy linux server

from their support page

https://support.godaddy.com/help/article/899/how-do-i-use-mod_rewrite

I came to know that it can be done from .htaccess

so I added a .htaccess to /public_html/mypages/

http://www.chrisabernethy.com/force-lower-case-urls-with-mod_rewrite/

here is the content of my .htaccess file

RewriteEngine On
RewriteMap  lc int:tolower
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule (.*) ${lc:$1} [R=301,L]

after this when I try to access any file www.myurl.com/Mypages/Page1.php its giving internal server error. Please help me resolve this issue .

I also tried adding

<IfModule mod_speling.c>
CheckSpelling On
CheckCaseOnly On
</IfModule>

and now I am not getting internal server error ,but I am getting

"file not found error"

www.myurl.com/mypages/page1.php -->working fine. but www.myurl.com/mypages/Page1.php --> "file not found error"

  • 写回答

2条回答 默认 最新

  • dooid3005 2015-02-24 04:52
    关注

    If you can load the mod_speling module. use this:

    RewriteEngine On
    AllowOverride All
    CheckSpelling on
    

    Otherwise; if you can't (you don't have control of it) force lowercase URLs with mod_rewrite (like you wrote on your question)

    RewriteEngine On
    RewriteMap  lc int:tolower
    RewriteCond %{REQUEST_URI} [A-Z]
    RewriteRule (.*) ${lc:$1} [R=301,L]
    

    Since your .htaccess was inside a folder and now is in the document root (public_html) try to add your rewrite. Maybe it was just an issue because, it wasn't in the document root.

    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)