如何使用get
网址提交表单方法mod_rewrite
?
这是我的代码
<form method="GET" action="https://www.example.com/search/">
<input type="text" name="search" value="" placeholder="search">
<input type="submit" value="OK">
</form>
当我提交表格时。它将重定向到
https://www.example.com/search/?search=test
如何将我的代码应用于重定向到
https://www.example.com/search/test/1
提交表格后?
答案 0 :(得分:0)
您的后端应设置Location
标题:
Location: https://your.domain/search/test/1
$ cat search/index.html
<form method="GET" action="https://your.domain/search/post.php">
<input type="text" name="search" value="" placeholder="search">
<input type="submit" value="OK">
</form>
$ cat search/post.php
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://your.domain/search/test.html");
exit();
?>
$ cat search/test.html
Redirection works fine
要动态决定重定向的位置,请检查$POST[ ]
哈希。