Search code examples
phpurlpostgetslash

Need some answer about example.php/example


I am doing on a project and i stumble upon on this while going through some code. I had tried to google but could not find a correct keyword to search regarding this question.

http://www.fruit.com/example.php/red

I am confuse with this and the end of a .php it still have a character /red for example. What is the purpose of this? Does it have something to do with POST method?


Solution

  • A possible explanation is that the developer is using .htaccess rewrite rules. It is most likely extra data that has to do with the page (such as you mentioned, POST and GET) and it's only done this way to make the URL look prettier or to simplify the URL.

    It is also sometimes done this way to make it easier to linkback to this page, especially if the page is being generated based on the data.

    A popular place to do this would be blogs. You often see blogs display links as:

    http://blog.com/blog/2001/02/23/how-pretty-is-this

    when in reality, the request to the server is something like:

    /blog.php?year=2001&month=02&day=23&title=how-pretty-is-this

    which isn't that pretty and not as easy to link-back to this particular page.