#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0

    Post Changing URL pattern


    I'm new to PHP and want to know is there a way that i can make my application effectively understand the url. Usually when I enter the URL http://www/example.com/hello/world, the control usually goes to index page at webroot/hello/world subfolder.

    What i wish to know is whether there is a way that the control always goes to index page at webroot , ie, http://www/example.com/index.php and consider the hello/world as GET parameters? It helps me to make a single controller page to decide what to do to a user request. I dont prefer to get a solution in any PHP framework as I've not started learning them.
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,113
    Rep Power
    9398
    Yes, with URL rewriting. It looks to the user like they're going to
    Code:
    http://www.example.com/hello/world
    but it actually works like
    Code:
    http://www.example.com/index.php/hello/world
    or
    http://www.example.com/index.php?hello/world
    or
    http://www.example.com/index.php?page=hello/world
    or pretty much anything you want. Point is the user doesn't know that's happening.

    So, (1) are you using Apache, (2) what do you want the URL to look like to the user, and (3) have you used the $_SERVER array much? The various possibilities are all equally easy to use.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    2
    Rep Power
    0
    Originally Posted by requinix
    Yes, with URL rewriting. It looks to the user like they're going to
    Code:
    http://www.example.com/hello/world
    but it actually works like
    Code:
    http://www.example.com/index.php/hello/world
    or
    http://www.example.com/index.php?hello/world
    or
    http://www.example.com/index.php?page=hello/world
    or pretty much anything you want. Point is the user doesn't know that's happening.

    So, (1) are you using Apache, (2) what do you want the URL to look like to the user, and (3) have you used the $_SERVER array much? The various possibilities are all equally easy to use.
    Yeah I use Apache server I've not much explored into $_SERVER array till now.
    I prefer the URL to be like http://www.example.com/hello/world
    I dont prefer any index.php or ?query-string on the URL. thank you for your reply

IMN logo majestic logo threadwatch logo seochat tools logo