-2

I have a URL

http://example.com/test/search.php?id=SearchWord

And i want to change this into

http://example.com/test/SearchWord

Now i tried somethings with .htaccess but i couldn't get it work because i need to $_GET['id'].

I have a if function that checks on $_GET['id'].

How do i do this with the new short URL and how to shorten the URL ?

Scott Solmer
  • 3,607
  • 6
  • 38
  • 67
Jason
  • 23
  • 1

3 Answers3

0

You can do this using mod_rewrite in apache.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

This will let you set a RegEx for the requested URL and forward it to a different URL!

meyer9
  • 1,060
  • 9
  • 26
0

In your .htaccess, give this a try:

RewriteEngine On
RewriteRule ^test/(.*)$ /test/search.php?id=$1 [L]
kyo
  • 625
  • 4
  • 7
0

Try this ...

RewriteEngine On
RewriteRule ^([^\.]+)$ search.php?id=$1 
Hakan Kose
  • 1,554
  • 7
  • 14