0

I have a HTML form which looks like this:

<form action="process.php" method="get">
    <input type="text" id="q" name="q" maxlength="16">
</form>

The process.php spits out some data, that's all working fine. When it has returned the data the URL looks like this:

website.com/process.php?q=banana

I would like to have a cleaner URL like this:

website.com/banana/

Is this possible using .htaccess? Thanks in advance!

user2534723
  • 115
  • 1
  • 2
  • 11
  • this question has been answered so many times : [here](http://stackoverflow.com/a/7945816/2858417) – zerzer Dec 31 '13 at 18:18
  • No, the request is to directly create an SEO-looking URL, not how to decode an SEO URL into a dynamic URL. – Phil Perry Dec 31 '13 at 18:21

2 Answers2

1

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

# external redirect from actual URL to pretty one
#RewriteCond %{THE_REQUEST} \s/+process\.php\?q=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^([^/]+)/?$ /process.php?q=$1 [L,QSA]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

I think you're going to have to use method="post" to hide the Query String in the URL. I can't think of any way to dictate the format of the URI when using a form submission, but maybe someone else can come up with something.

Phil Perry
  • 2,126
  • 14
  • 18