【发布时间】:2015-07-19 03:32:58
【问题描述】:
我正在尝试将我网站上的以下所有 URL 重定向到新版本。这是目标:
之前(注意没有'.php')
https://example.com/view?username=asdf1234
重定向到(使用“.php”并在“工具”文件夹内)
https://example.com/tool/view.php?username=asdf1234
我尝试了几个示例,但无法弄清楚。这是我最好的猜测
RewriteEngine On
RewriteRule ^/view\?username=(.+) /tool/view.php?%1 [L,R=301]
添加
RewriteEngine On
RedirectMatch ^/view(.*)$ https://example.com/tool/view.php$1
已成功重定向,但它是 302 重定向。当我添加 [L,R=301] 时,它给出了 500 错误。
【问题讨论】:
标签: .htaccess redirect get wildcard http-status-code-301