HTML image src case sensitivity

冷暖自知 提交于 2019-12-05 13:57:29

Either you can use JS to do this using toLowerCase(), or you need to rename them by yourself.

Also, it depends on the server, and HTML has nothing to do with this, UNIX Servers are case sensitive, whereas Microsoft servers are case insensitive.

Also if you are using any server side language, like PHP, you can use strtolower() as well which would be even better, as client can have JavaScript turned off in which, your page will fail to render images.

This really depends on what OS your web server is running - for example OSX is not case sensitive on the file system but Linux is.

You could create a regex to rewrite the request - apache offers mod_rewrite - but I find it best to create a convention and stick to it - I assume things will be case sensitive so that if I port the site I do not have any issues.

I think you can use .htaccess and RewriteRule to change the path on request. Something like this:

RewriteRule ^IMAGES/(.*)\.(jpg|jpeg|gif|png)$ images/$1.$2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!