regex - 301 .htaccess 重定向 apache 服务器
问题描述
所以我遇到了我想要所有请求的问题
https://transfinmedia.com/author?url=akchopra1-A268
被301重定向
https://transfinmedia.com/author/akchopra1-A268
但是当我使用
RewriteEngine on
RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule ^author(.*) /author/%1 [L,R=301,NC]
请求
https://transfinmedia.com/author?url=akchopra1-A268被重定向到
https://transfinmedia.com/author/akchopra1-A268?url=akchopra1-A268
我在这里做错了什么,完全不知道。
解决方案
默认情况下,mod-rewrite 将 old 附加QueryString
到新的目标 url。要丢弃 QueryString ,您需要?
在目标 url 的末尾放置一个(空问号)。
RewriteEngine on
RewriteCond %{QUERY_STRING} url=(.*)
RewriteRule ^author(.*) /author/%1? [L,R=301,NC]
确保在使用之前清除浏览器缓存。
推荐阅读
- angular - 在订阅方法中设置时变量未在模板中更新
- x86 - ZombieLoad 的微架构根本原因是什么?
- python - 作为两个子流程的中介的 subprocess.PIPE 何时关闭?
- javascript - Angular 7 - 如何将 HTTP 请求与 observable 链接起来
- set - momentJS 链接 setter .year().day() 返回错误的日期
- java - 根据要替换的内容,我如何用单个项目替换多个项目
- javascript - 左侧单独存在空对象时出现 JavaScript 错误
- hadoop - hbase completebulkload 长时间运行
- kotlin - Ktor reflection to create custom WebSocket session doesn't update constructor parameters
- c++ - 为什么基本正则表达式“\[”在 C 中有效,但在 C++ 中无效?