首页 > 解决方案 > 如何使用 htaccess 隐藏原始图像路径

问题描述

我正在尝试从我的 WordPress 网站隐藏原始图像路径。在哪里不起作用。但其他规则工作正常。

我试过像

RewriteRule ^wp_unisol/img/([^/]+)$ wp_unisol/images/$1 [L]

但它不工作。

当我检查 .htaccess 检查器时,它显示为真。

我需要像下面这样的图像路径

原始路径: https ://clickthedemo.com/wp_unisol/images/noimgavailable.jpg

预期路径: https ://clickthedemo.com/wp_unisol/img/noimgavailable.jpg

我知道这个问题之前问过,但它没有帮助

标签: wordpress.htaccess

解决方案


用这个:

RewriteEngine On
RewriteRule ^img/([^/]+)$ images/$1 [L]

并确保将其放在.htaccess文件顶部或至少在 WordPress 重写规则之前。


推荐阅读