.htaccess - .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]
解决方案
推荐阅读
- apache-spark - Pyspark Hive S3 Parquet 文件:org.apache.spark.util.TaskCompletionListenerException:内容长度分隔的消息正文过早结束
- apache-kafka - 有没有办法在 Kafka ProducerRecord 被序列化后拦截它?
- excel - GET.WORKBOOK 函数在文件重新打开时无效(excel)
- python - 没有异常时打印回溯到文件
- reactjs - 未使用 react-testing-library 调用模拟函数,但调用了原始函数
- outlook - Outlook电子邮件附件名称重复,如何按附件号保存?
- c++ - 这是在 C++ 中计算线程数的好方法吗?
- reactjs - React-particles-js 适用于 localhost 但不适用于 gh-pages
- flutter - 如何清理 pdf 视图
- git - 如何使用 GitLab CI/CD 合并分支?