0

我网站上的以下表格

<form name="vine" action="create.php" method="get">
<input name="id" type="text" value="Vine ID" id="id">
<br>
<input type="submit" value="Submit">
</form>

我的 .htaccess 包含以下内容

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w\d~%.:_\-]+)$ index.php?id=$1 [NC]

几乎我在表单中提交的所有内容都将我带到 create.php,除非我提交的字符串以“http://”开头。当它以“http://”开头时,它会将我重定向到我的主页。如何在 $_GET 中传递完整的 url 而无需重定向主页?

4

1 回答 1

1

您是否尝试过使用 javascript 内置函数 encodeURI() 和 encodeURIComponent()?

这将为 GET 请求编码 url。

如果你使用 jQuery:

$(document).on("click","input[type='submit']",function(e) {
  e.preventDefault();
  $("#id").val(encodeURIComponent($("#id").val()));
  $(this).off('submit').submit();
});
于 2013-05-31T00:48:09.127 回答