SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    making clean urls using PHP ??

    Hello forums !!
    I am bored with working with the url with query string urls ie("http://localhost/my_project/index.php?page=test&action=create").
    Now i would like to work with clean urls like "http://localhost/my_project/test/create"
    I would like to rewrite the url without using mod_rewrite module rather i would like to use PHP.
    How to explode the urls to get the required parameters ?
    Note: I am working under the my_project folder
    Any comments n suggestions are warmly welcome.
    Thanks in advance to all of you.

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why don't you want mod_rewrite?

    it can solve all your problems, and more.

  3. #3
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first i should try with using PHP and if succeed then using mod_rewrite.
    Its not that i will not be using mod_rewrite..Ok then plz let me know.
    i had the following case:
    if i had the following url: http://localhost/my_project/test/create
    I would to map this url with http://localhost/my_project/index.php?url=/test/create/
    So that its easier to retrieve the params using $_GET['url'] and everything will go fine.
    How it could be performed? thanks in advance.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteCond %{REQUEST_FILENAME} !-d # If the directory doesn't exist run the rule.
    RewriteCond %{REQUEST_FILENAME} !-f # if the file doesn't exist run the rule.
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
    http://localhost/my_project/test/create
    if test/create is not a real folder or file it will be rewritten as http://localhost/my_project/index.php?url=/test/create/
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how to enable $_SERVER['PATH_INFO'], it says undefined index PATH_INFO.

  6. #6
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    that's because there is no "PATH_INFO" in $_SERVER.

    You won't be able to change the url with PHP. It just can't be done. Theres no logic in it, because mod_rewrite calls the PHP script, but without it it wouldn't know what to do.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  7. #7
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    Malaysia
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check out cakePHP, everything is done for you

  8. #8
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    To use PATH_INFO you need to have AcceptPathInfo in Apaches conf file on.
    http://httpd.apache.org/docs/2.2/mod...acceptpathinfo
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  9. #9
    SitePoint Member
    Join Date
    Sep 2007
    Location
    Melbourne, Australia
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CodeIgniter is a simpler solution over cakephp, it is light and easy to learn..

    Good luck..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •