...

View Full Version : Mod_rewrite question



toolglutton
01-18-2011, 05:31 AM
I am totally new to mod_rewrite. Anyone can help me with this?

I am using a html to call for the search.php to search mysql database. For example, if I search num1, the url of the search result is shown as www.mywebsite.com/search.php.

How do I write the RewriteRule so that it will be shown as www.myurl.com/Data/num1?

Thank you very much.

toolglutton
01-21-2011, 03:59 PM
Anybody could help me?



I am using a html to call for the search.php to search mysql database. For example, if I search num1, the url of the search result is shown as www.mywebsite.com/search.php.

How do I write the RewriteRule so that it will be shown as www.myurl.com/Data/num1?

Thank you very much.

djm0219
01-21-2011, 04:51 PM
If what is being searched for is coming from a form field on the HTML page you won't be able to rewrite anything to get the desired result. The server, Apache, doesn't "see" things that are entered on forms.

Lamped
01-22-2011, 11:29 AM
I made a similar system. You need a script (PHP or so) to catch the form data and redirect it, like:


header('Location: /Data/'.urlencode($_REQUEST['query']), 301);
die();

The rewrite rule you're looking for is something like:


RewriteRule ^Data/(.+)$ /search.php?query=$1 [L]



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum