Forum Moderators: open
This form directs the brwoser to:
example.com/search/?foo=keyword.
Is it possible to direct the browser to:
example.com/search/foo/keyword instead?
Notice I don't want the '?' or '=' in the url.
Does anyone know how (if) I can achieve this? If no is there an alternative?
I can't find the answer anywhere so I am begining to think it is impossible, which would be a shame.
Regards,
the answer to your question has two parts.
first, you should send an external redirect that the browser can use to request your preferred url.
then your server should be set up to handle the preferred url, either with documents in a directory structure matching the url path or using internal rewrites to resolvable urls.
I am not using the POST method as I would like the user to have the url. (As a resource or so)
Could you explain more about sending an external redirect that the browser can use to request your preferred url. That went a bit over my head, sorry ;-).
I am currently using mod_rewrite to handle the directory type structure. My thinking is that once the form directs the browser to the URL I want mod_rewrite should be handle it.
my form ACTION is now set to test.php (show below).
<?php
header("Location: http://example.com/$foo"); /* Redirect browser */
exit;
?>
This then directs the browser to example.com/keyword.
Is this the standard way of doing this?
p.s Thank you for your time and help phranque, grealty appreciated.