How do I make URLs case insensitive in Linux server

非 Y 不嫁゛ 提交于 2019-11-27 12:27:29

You can easily make the apache webserver ignore the case by using the mod_speling module, which is part of the standard apache distribution:

CheckSpelling On
CheckCaseOnly On

After restarting httpd you can access read as Read or READ or read.

sonorita

Hi I got the solution finally. Placed the below code in /etc/httpd/conf/httpd.conf.

LoadModule speling_module modules/mod_speling.so

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

Then restart httpd:

sudo service httpd restart

And finally verify it is enabled:

sudo httpd -M | grep speling

That should yield speling_module (shared)

Thanks for the help for all..

First install speling_module. Then include LoadModule speling_module modules/mod_speling.so in httpd.conf file and then include

<IfModule mod_speling.c>
     CheckSpelling On
     CheckCaseOnly On
</IfModule>
in httpd.conf, then restart httpd service using service httpd restart command.

Hi not sure if this helps but this is the simple workabout i have used, it uses a very basic php page but it works for the site i needed it to.

Place this code in the htaccess file

 AddType application/x-httpd-php .html .htm
 ErrorDocument 404 /404.php

I have then created a php file wit the following..

 <?php
 $aurl = $_SERVER['REQUEST_URI'];
 $lurl = strtolower($aurl);

 if($aurl != $lurl){
header('location:'.$lurl);
 } else {
header('location:/404.html');
 }
 ?>

Basically it gets the referring url -> stores as $aurl

it then makes it lowercase -> stores as $lurl

if they are not matching it then trys to display the lowercase url ($lurl)

If that fails the page does not exist, the refering url is now the same ( $lurl == $aurl ) so it then redirects to a proper 404 page or can display some extra code..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!