如何使用.htaccess添加文件类型扩展名?

问题描述:

我想将 http://example.com/STRING 之类的链接映射到 http://example.com/STRING.png ,如何使用.htaccess?

I want to map links like http://example.com/STRING to http://example.com/STRING.png, how to do it with .htaccess?

尝试在htaccess中使用以下代码:

Try the following code in htaccess :

RewriteEngine on


RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.png -f

RewriteRule ^([^/]+)/?$ /$1.png [NC,L]