使用 urlencoded 参数重写 url
我发送一个 urlencoded 地址作为名为 fromurl 到我的页面
http://localhost/myapp/admin/login.php
:
http://localhost/myapp/admin/login.php?fromurl=%2Fmyapp%2Fadmin%2F
我想使用 mod_rewrite
在表单上启用更好的 URL,我对此很满意新到。上面示例的更好的 URL 变体将具有以下形式:
http://localhost/myapp/admin/login/%2Fmyapp%2Fadmin%2F
我已在 .htaccess
中尝试了这一行,但没有工作(无法找到 URL):
RewriteRule ^admin/login/(.*)$ admin/login.php?fromurl=$1
我还有其他 mod_rewrite规则工作。在这种情况下我应该如何编写RewriteRule?
I send an urlencoded address as a GET parameter called fromurl
to my page http://localhost/myapp/admin/login.php
:
http://localhost/myapp/admin/login.php?fromurl=%2Fmyapp%2Fadmin%2F
I would like to enable a nicer URL on the form using mod_rewrite
which I am quite new to. The nicer URL variant of the example above would have the form:
http://localhost/myapp/admin/login/%2Fmyapp%2Fadmin%2F
I have tried this line in .htaccess
which did not work (the URL can not be found):
RewriteRule ^admin/login/(.*)$ admin/login.php?fromurl=$1
I have other mod_rewrite
rules working. How should I write the RewriteRule in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试转义斜杠:
此外,您可能需要添加重写库(在重写规则之前),因为您没有通过专用主机名访问它
Try escaping your slashes:
Additionally, you might need to add a rewritebase (before the rewrite rule) because you aren't accessing this via a dedicated hostname