SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to change (?,&) in the link to (/) ?

    Hi

    I had read once artical how to do handle the submit values from the link as folder, i mean the link will look like this :

    http://site.com/showartical/full/14

    this link is the same as :

    http://site.com/showartical.php?t=full&id=14



    how can i do this , and which way is better ?




    thx.

  2. #2
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First way is better, but you would need to use something like the following

    PHP Code:
    $qStr explode'/'$_SERVER['PATH_INFO'] );
    $t    $qStr[1];
    $id   $qStr[2]; 
    Now, to use a file without an extension like you did below, you would have to put this in a htaccess file:

    Code:
    <Files filename>
        ForceType application-httpd-php
    </Files>
    Im pretty sure my file type is wrong, but I don't have time to look for it atm

    Eric
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My try at it:

    PHP Code:
    <?php

    $new_url 
    $_SERVER['PATH_INFO'];

    $new_url str_replace("&""/"$new_url);
    $new_url str_replace("?""/"$new_url);

    $URL $_SERVER['PHP_SELF']."".$new_url;
    // Outputting: /dir/file.php/act/whatever/

    header("Location: ".$URL);
    But as I read the thread, I might be on the wrong topic/idea

  4. #4
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If your using path info, they are already in the / form dude

    somesite.com/file.php/val1/val2/val3 , everything from the / after file.php is in $_SERVER['PATH_INFO'], look below:

    PHP Code:
    // url is somesite.com/file.php/val1/val2/val3

    $qStr explode'/'$_SERVER['PATH_INFO'] );

    $val1 $qStr[1];
    $val2 $qStr[2];
    $val3 $qStr[3];

    // or you can do it like this

    list( , $val1$val2$val3 ) = explode'/'$_SERVER['PATH_INFO'] ); 
    Note, it IS supposed to be list( , $val1... First value is going to be blank, therefor a dummy, no need to assin it to a variable.

    -Eric
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  5. #5
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well thx alot guys !

  6. #6
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    i cann`t get $_SERVER['PATH_INFO'] !!

    PHP Code:
    echo $_SERVER['PATH_INFO']; 
    i got nothing , am using php 4.2.2 !

    is there somthing to change on apache config ot php.ini ?

  7. #7
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is it the same result as $_SERVER['PHP_SELF'] ?

  8. #8
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Errrr, I don't know quite honestly...


    PHP_SELF:

    /URI/to/file.php

    I'm not sure, but it might be..

    Regards,
    Someonewhois

    P.S I was going the wrong way.

  9. #9
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should be using $_ENV['PWD'];

    Aaron
    Aaron Brazell
    Technosailor



  10. #10
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are talking about this article.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky

  11. #11
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by Sketch
    you should be using $_ENV['PWD'];

    Aaron

    also i got nothing !!!


    weirdbeardmt ;
    not this artical, maybe in phpbuilder, but i cann`t find it now !

    the result of $PHP_SELF is :
    http://site.com/dir/x.php

    $PHP_SLEF = /dir/x.php


    i got 'maybe' strange , when i write echo $_SERVER['PATH_INFO'], i got nothing , but with explode it i got the vars, az Zaire code !

  12. #12
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using $_SERVER['PATH_INFO'] your URL MUST be like this:

    file.php/val1/val2/val3/val4

    or it fill mess up, everything after the filename ( file.php ) will show up in $_SERVER['PATH_INFO']
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  13. #13
    .NET inside archigamer's Avatar
    Join Date
    Jan 2002
    Location
    Strongsville OH
    Posts
    1,534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why not have a look at the mod-rewrite module to acomplish this, there was article published about it on october 21 this year. It is good in my opinion.
    Web Finesse Studios
    Professional, business oriented web hosting and development.

  14. #14
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by archigamer
    why not have a look at the mod-rewrite module to acomplish this, there was article published about it on october 21 this year. It is good in my opinion.

    link ?

  15. #15
    SitePoint Enthusiast xor's Avatar
    Join Date
    Jul 2001
    Location
    New Zealand
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaire
    Now, to use a file without an extension like you did below, you would have to put this in a htaccess file:

    Code:
    <Files filename>
        ForceType application-httpd-php
    </Files>
    Im pretty sure my file type is wrong, but I don't have time to look for it atm

    Eric
    You are right Eric, it should be...

    Code:
    ForceType application/x-httpd-php
    I used files with no extension, eg. a file called 'photo' to display my photos, looks like a directory from the URL though. Subsequent query string (I like to call them 'Query Path') parameters can be pulled out my methods similar to those already mentioned. It works great!


  16. #16
    Ribbit... Eric.Coleman's Avatar
    Join Date
    Jun 2001
    Location
    In your basement
    Posts
    1,268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't have $_SERVER['PATH_INFO'] available... i can guess your problem!

    If running Apache 2, you need to add

    Code:
     AcceptPathInfo On
    inside where you define your variables for your site (httpd.conf)
    Eric Coleman
    We're consentratin' on fallin' apart
    We were contenders, now throwin' the fight
    I just wanna believe, I just wanna believe in us

  17. #17
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You right Zaire ...

    but i had slove this problem from weeks ago

    thx anyway

  18. #18
    SitePoint Enthusiast xor's Avatar
    Join Date
    Jul 2001
    Location
    New Zealand
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Zaire
    somesite.com/file.php/val1/val2/val3 , everything from the / after file.php is in $_SERVER['PATH_INFO'], look below:

    PHP Code:
    // url is somesite.com/file.php/val1/val2/val3

    $qStr explode'/'$_SERVER['PATH_INFO'] );

    $val1 $qStr[1];
    $val2 $qStr[2];
    $val3 $qStr[3];

    // or you can do it like this

    list( , $val1$val2$val3 ) = explode'/'$_SERVER['PATH_INFO'] ); 
    Note, it IS supposed to be list( , $val1... First value is going to be blank, therefor a dummy, no need to assin it to a variable.

    -Eric
    I've had code like this working just fine, and I even got rid of the file.php using ForceType directives (this was on W2K, Apache2). Now on my new development machine, using WinXP, Apache 1.3 not even this simple version works!
    somesite.com/test.php/val1/val2/val3
    I know my php code is working because if I just go to test.php it's fine and doing what I expect. However as soon as I add query parameters such as test.php/foo I get 'No input file specified' error -- that's all that appears on the page. Argh! I am thinking it's an Apache thing, but I've gone through httpd.conf file and can't see what it is -- I'm an apache newbie though, so bear that in mind. Any ideas what might be happening?


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
  •