当我输入" http://example.com/Hello%20There/ "时,它会显示索引页面:" http://example.com/Hello%20There/index.html ".
好吧,我想要做的是当用户键入" http://example.com/Hello%20There "时(所以与第一个类似,除了它没有尾部斜杠).
我尝试了许多东西,特别是正则表达式,但没有任何作用,因为我认为服务器在找到空格(URL中的"%20")时停止了reg exp过程.
我试过这个reg exp:
Options +FollowSymLinks
rewriteEngine On rewriteCond %{REQUEST_URI} ^(.*)\ (.*html)$
rewriteRule ^.*$ %1-%2 [E=space_replacer:%1-%2]
rewriteCond %{ENV:space_replacer}!^$
rewriteCond %{ENV:space_replacer}!^.*\ .*$
rewriteRule ^.*$ %{ENV:space_replacer} [R=301,L]
Run Code Online (Sandbox Code Playgroud)
并且还说:
DirectorySlash On
Run Code Online (Sandbox Code Playgroud)
在Apache的"mod_dir"模块中.
所以,我的问题是: - 当用户输入没有尾部斜杠的网址时,如何告诉服务器添加尾部斜杠; $