首页 > 解决方案 > .htaccess 重写规则以去除扩展名不起作用?

问题描述

我不明白为什么这不起作用。它应该采用任何带有 .htm 扩展名的页面并将其剥离。那将是 WordPress 网站上的页面。但是当它运行时,.htm 会停留并得到 404。我错过了什么?

RewriteEngine On
# there is an existing rule here that works fine with [R=301,L]
# but the following rule isn't working?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/([^./]+)\.htm$ /$1/ [R=301,L]

这个有效:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.htm$ $1/ [R=301,L]

标签: .htaccessmod-rewrite

解决方案


推荐阅读