Convert to lowercase in a mod_rewrite rule

前端 未结 3 1624
梦如初夏
梦如初夏 2020-11-29 10:18

I would like URLs like server.com/foo to be case-insensitive. But server.com/foo actually gets mod_rewrite\'d to server.com/somedir/foo

(Assume that all the files in

3条回答
  •  一个人的身影
    2020-11-29 11:00

    First, put the following line in the section of your .conf file. (For me that lives at /etc/httpd/vhosts.d/00foo.conf.)

    RewriteMap lc int:tolower 
    

    You can replace lc with any name you want. Then restart apache, which you can do with sudo service httpd restart.

    Finally, add this in your .htaccess file:

    RewriteRule ^/(.*)$ /${lc:$1} 
    

提交回复
热议问题