0

I have made a search engine for my website and I want to know how to make the URL like Google Search or YouTube where it has...

http://sitename.com/search?q=search+query

I can only get it like this...

http://sitename.com/search.php?q=search+query

I want to find out how to take off the '.php'. putting it in a folder called search just mean it's like this...

http://sitename.com/search/?q=search+query

Hope you know what I mean and have enough information to help. Thanks.

2 Answers2

0

inside sitename.com, create a directory called search. Your filename should not be search.php, use index.php instead. Then target it using the url, http://sitename.com/search/?q=search+query.

http://sitename.com/
search
index.php

That's obviously the simplest way. The other way is to use .htaccess mod_rewrite to rewrite your url. It might not be what you want, but would bring you close to what you want, if rename your file is not an issue

Pretty URLs for search pages

Community
  • 1
  • 1
Steward Godwin Jornsen
  • 1,181
  • 1
  • 7
  • 13
0

Put this code in your .htaccess under DOCUMENT_ROOT directory or in httpd.conf:

Options +MultiViews

Once that is done apache will support:

http://sitename.com/search?q=search+query

by executing search.php

anubhava
  • 761,203
  • 64
  • 569
  • 643