Reputation: 45
I want to change the search URL my website makes after a search in my search box. The URL it now shows is: search.php?name=i&submit=
I was looking on an .htaccess page and made this:
RewriteEngine On
RewriteRule /search.php?name=i&submit= /?s=i
But the URL still is the same. Anybody knows how to do this?
The URL data comes out of this:
if(isset($_GET['submit'])) {
$string = $_GET['name'];
$sql = "SELECT * FROM user_name WHERE first_name LIKE '%{$string}%'";
}
Thanks.
Upvotes: 2
Views: 49
Reputation: 92854
You have to capture your GET
parameters explicitly:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{QUERY_STRING} name=([0-9a-z]+)&(.+)$ [NC]
RewriteRule (.*) /$1?s=%1 [R=301,L]
Upvotes: 1