.htaccess 重定向目录树中的所有 .shtml 文件,其他文件不理会



我在重定向/重写方面很糟糕。 我在网站的特定子目录树中有许多 .shtml 文件,我想将其 301 .html。 所有其他 .shtml 文件都应单独保留。 使用 Apache 时,RewriteEngine 处于打开状态。

具体来说,将www.domain.com/homes/cityname/file.shtml更改为.html对于许多城市和文件。homes子目录是常量。

www.domain.com/status.shtml保持原样

,等等。

尝试:

RedirectMatch 301 ^/homes/(.*).shtml /homes/$1.html

如果您宁愿使用mod_rewrite而不是mod_alias:

RewriteRule ^homes/(.*).shtml /homes/$1.html [R=301]

相关内容

最新更新