当我输入“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]
,并也提出:
DirectorySlash On
阿帕奇 “mod_dir” 模块中。
所以,我的问题是: - 如何判断服务器添加一个尾随斜线当用户键入一个URL 不带后缀斜线; $
你错过了在第二重写规则括号。 – 2017-09-06 11:49:55
请问,这是最终使用的规则组合吗?我对这个问题非常感兴趣,而且我无法正常运行......谢谢 – 2017-11-09 11:26:55