【发布时间】:2020-12-29 17:13:28
【问题描述】:
我正在尝试将我的 URL http://windllfiles.com/dlldata.php?name=All.dll 更改为 http://windllfiles.com/All.dll/ 和 http://windllfiles.com/?character=B 更改为 http://windllfiles.com/character/B/
我正在尝试将 http://windllfiles.com/dlldata.php?name=All.dll 的重定向 URL 写为
Options +FollowSymLinks
RewriteEngine on
RewriteRule dlldata/name/(.*)/ dlldata.php?name=$1
RewriteRule dlldata/name/(.*) dlldata.php?name=$1
对于http://windllfiles.com/?character=B as
Options +FollowSymLinks
RewriteEngine on
RewriteRule /character/(.*)/ ?character=$1
RewriteRule /character/(.*) ?character=$1
但两者都不起作用
【问题讨论】:
-
.包含/。使用[^/]+,因为它不是正斜杠。您也可以使用/?使斜杠成为可选的,那么您只需要1 条重写规则。能否请您更新完整的.htaccess。RewriteEngine on不应出现两次,多个规则可能会发生冲突 -
好像问题也写反了,
http://windllfiles.com/character/B/->http://windllfiles.com/?character=B和http://windllfiles.com/All.dll/->http://windllfiles.com/dlldata.php?name=All.dll,对吧? -
你能解释一下吗?
-
哪一部分?
.表示任何单个字符。/符合该规则。 -
根据this meta post 和this meta post,这个问题对于SO 来说根本不是题外话,所以近距离投票是错误的。这已经被反复讨论过,并且已经确定大多数重写规则是由 Web 应用程序/框架的开发人员创建和维护的。
标签: regex .htaccess mod-rewrite