繁体   English   中英

如何将“www.example.com/test.html”转为“www.example.com/test”? (.htaccess)

[英]How do I turn “www.example.com/test.html” to “www.example.com/test” ? (.htaccess)

我写了一个 .htaccess 文件:

RewriteEngine On
RewriteRule ^test test.html [NC,L]

但我不明白为什么如果我将 go(例如)转到“example.com/testabc”,它会引导我到 test.html 无论如何。 我该如何关闭它? 我知道这是一件简单的事情,但我找不到解决方案......

看你的表情:

 ^test

https://regex101.com/将其翻译成英文:

^ 在行首断言 position
test 从字面上匹配字符 test(区分大小写)

所以你有一个“开始于”但没有“结束于”

^test$

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM