.htaccess - 从 Htaccess 重定向 URL 中的 Tailing Dash
问题描述
我正在尝试使用 mod rewrite 或重定向 301 重定向包含在某些 URL 末尾的一些破折号。
有许多 URL 受此结构影响。
http://example.com/nested/any-name-.html
to
http://example.com/nested/any-name.html
我发现了这一点,但它最后不适用于 .html 。
RewriteRule ^(.*)-$ http://example.com/nested/$1 [L,R=301]
解决方案
您可以使用:
RewriteRule ^(.+)-(\.html)?$ $1$2 [L,R=301]
推荐阅读
- python - 如何逐行读取“数据”属性?Python
- python - 访问全局字典
- javascript - 手动设置日期时如何防止日期选择器触发事件
- twitter - twitter 卡验证器错误:未找到卡(卡错误),即使我有元标记
- apache-spark - 使用 PySpark 和 Babel 将浮点数格式化为货币
- r - 在 R 中交叉验证后如何在测试数据集上应用 knn 模型
- r - 使用R从不同位置的多列中提取信息
- jquery - SSO 链接在 SharePoint 2013 网站的 Edge 浏览器中不起作用
- android - 将 WearOS APK 从嵌入式迁移到多 APK - 使用什么版本代码来保留移动 APK?
- ios - 将 Firebase 数据传递给 CollectionTableCellModel 中的函数