.htaccess 重定向后丢失 URL 参数/$_GET 和 $_POST
我有一个 php 文件,例如: http://www.domain.com/?mod= test&act=view
我想创建从该地址到类似以下内容的重定向: http: //www.domain.com/view-test
这样每次用户访问第一个 URI,它被重定向到 http://www.domain.com/view-test 查看第一个 uri 的内容。
我有以下规则:
RewriteCond %{QUERY_STRING} mod=test&act=view
RewriteRule ^$ view-test? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^view-test.html amas/index.php?mod=test&act=view [L]
这对于没有参数或表单提交的页面效果很好,但如果我有任何这些,则不起作用。
这意味着如果我有一个提交到同一文件的表单,它将无法工作。如果我有类似 http://domain.com/?mod=test& act=view&order_by=id 我留下重定向到 uri 并且 order_by 参数被忽略!
是否有可能做我正在尝试的事情?我对此了解不多,说实话,我在找到的所有信息中迷失了......:/
I have a php file like: http://www.domain.com/?mod=test&act=view
And I want to create a redirection from that address to something like: http://www.domain.com/view-test
so that everytime a user accesses the first uri it gets redirected to http://www.domain.com/view-test viewing the content of the first uri.
I have the following rules:
RewriteCond %{QUERY_STRING} mod=test&act=view
RewriteRule ^$ view-test? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^view-test.html amas/index.php?mod=test&act=view [L]
This works fine for pages without parameters or forms submissions but If I have any of those nothing works.
Meaning that if I have a form that is submitting to the same file it won't work. If i have something like http://domain.com/?mod=test&act=view&order_by=id i'm left with the redirected to uri and the order_by parameter is ignored!
Is it even possible to do what I'm trying? I don't really know much about this and to be honest I'm lost between all the info I find... :/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用查询字符串追加:
Use Query String Append: