user2259279
user2259279

Reputation: 23

Why does it redirect home?

the following form on my site

<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>

and my .htaccess contains the following

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

Almost everything I submit in the form takes me to create.php, except when the string I submit starts with "http://". When it starts with "http://" It redirects me to my homepage. How would I pass a full url in a $_GET without redirecting home?

Upvotes: 0

Views: 66

Answers (1)

Nikola R.
Nikola R.

Reputation: 1173

Have you tried using javascript built-in function encodeURI() and encodeURIComponent()?

That will encode url for GET request.

If you use jQuery:

$(document).on("click","input[type='submit']",function(e) {
  e.preventDefault();
  $("#id").val(encodeURIComponent($("#id").val()));
  $(this).off('submit').submit();
});

Upvotes: 1

Related Questions