Jump to content

PHP URLs


Norman

Recommended Posts

Hello, I would like to know wich ways are possible in PHP for our pages' urls. I mean.. 1) example.com/?search=test2) example.com/search?q=test3) example.com/search/?query=testetc. How do I do these? I'm not sure on how can I explain this..I'm new to PHP and I would like to know wich ways are possible in php for pages' urls, as said. Can you please help me? :)

Link to comment
Share on other sites

You'll have to change the .htaccess file, this doesn't have to do with PHP.Search in Google for RewriteRule and RewriteCond or mod_rewrite.

Link to comment
Share on other sites

Yes, but for example.. on a PHP page I have, I'm using this code in it:

<form action="#" method="get"><input type="text" name="search" /> <button id="dsearch_buttom">Search</button></form>

And when I put something there, and I clik on 'submit', I get this url: example.com//?search=blabla#..

Link to comment
Share on other sites

Ok, then it depends only from the GET method I'm using on my form. But how do PHP urls (the one wich aren't 'friendly') works? How do I set for a url to become example.com/?search=test&forumid=10&method=textonly..? I need the explanation, not the code.

Link to comment
Share on other sites

There are no different "ways" of PHP for pages' URLs. All three examples you show mean different things (assuming typical Apache configuration and no mod_rewrite):1. Equivalent to saying

example.com/index.php?search=test

and means that a $_GET variable named "search" with a value of "test" will be supplied to the index.php file.2. Open the "search" file (no extension?!?) and supply it with a $_GET variable named "q" with a value of "test".3. Equivalent of saying

example.com/search/index.php?query=test

(i.e. open index.php located in a directory "search" under the documentRoot)and provide it with a $_GET variable named "query" with a value of "test".In the case of the "post" method, variables get into the $_POST array instead. You could use Fiddler (see my signature) to see exactly what the server receives with each form submittion, but at this early stage, be warned that looking at this raw information may either clear things up OR confuse you even more, so only use Fiddler as a last resort.Read the W3School tutorials to learn how to use the $_GET and $_POST variables.And if you want to learn how to make user friendly URLs, so that

example.com/search/something

becomes equivalent to

example.com/?search=something

you should read up on Apache's mod_rewrite, or if you feel too lazy for that, just use a clean PHP URL handler, and learn more about PHP instead.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...