.htaccess重定向包含空格的网址

Ste*_*rst 13 .htaccess redirect

我有一个我无法控制的花药网站的链接 http://example.com/one two three.exe

正确的URL是 http://example.com/one_two_three.exe

请注意下划线而不是空格.

我搜索了互联网,发现了.htaccess的代码片段

# Redirect old file path to new file path
Redirect /one%20two%20three.exe http://example.com/one_two_three.exe
Run Code Online (Sandbox Code Playgroud)

我将此片段添加到文件顶部的预先存在的根.htaccess中.
但它似乎没有用.我的浏览器没有重定向,我得到一个404错误页面.

我相信它与原始URL中的空格有关,但我不知道如何处理URL中的空格.

建议?

KM.*_*KM. 29

你可以尝试几件事(都是未经测试的)

Redirect "/one two three.exe" http://example.com/one_two_three.exe
Run Code Online (Sandbox Code Playgroud)

或使用RewriteRule而不是Redirect:

RewriteRule /one\ two\ three.exe http://example.com/one_two_three.exe
Run Code Online (Sandbox Code Playgroud)