Hi, i have a form that returns the value as /?Field=TextText How can i mod_rewrite redirect that value to Domain.com/TextText? Thanks
You can use: RewriteRule ^(.*)/$ index.php?Field=$1 PHP: and access directly to domain.com/TextText/ Regards
Thanks, but i already have this rule.. the problem is, the form directs to /?Field=TextText so i need to redirect the url from the form action?
Could you paste the portion of code here to check it? I think you have to use domain.com/TextText/ directly on the form action.
Hmm, simply said: i just don't want /?Search=TextText as search result, instead i want /TextText after the form action.. Does this only work with JavaScript?
Yes, any solution would be JS only. You could fake it by having the form post to a php script which then uses header() to redirect to the domain.com/TextText/ url, but other than that, JS only.
Thanks for help, redirect sounds good.. but i didn't get Sky's code to work.. any ideas? <?php if($_GET['Field']){ header("Location: /".$_GET['Field']."/"); } ?> PHP:
I see, sorry for posting rubbish then. Yes, the only way doing this would be javascript I guess, like this; <script type="text/javascript"> function my_url(){ window.location = "/"+document.getElementById("search").value+"/"; } </script> <form method="get" action="index.php"> <input type="text" name="search" id="search" /> </form> <input type="submit" onclick="javascript: my_url()" /> Code (markup): EDIT: What do you mean, did you get any errors?
Onsubmit then <script type="text/javascript"> function my_url(){ window.location = "/"+document.getElementById("search").value+"/"; return false; } </script> <form method="get" action="index.php" onsubmit="javascript: return my_url()"> <input type="text" name="search" id="search" /> <input type="submit" /> </form> Code (markup):
Hrm.. OnSubmit does the same as action, pointing to /?Field=TextText in this case-_- Any more ideas? What code can i put into redirect.php?
Can we see the real code then? As it's kinda hard to code something while you don't know if it would work. Also why, would onsubmit not work in this case, it works perfectly here. And, did you do what aaron adviced? Did you change the get variable with the name of your form?