Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    Another simple url rewrite

    I want to turn articles/4.html into news.php?id=4

    Any ideas?

  • #2
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    *bump*

  • #3
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    *bump*

  • #4
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    any ideas how to do this?

  • #5
    Regular Coder Rappa's Avatar
    Join Date
    Nov 2005
    Location
    LI
    Posts
    356
    Thanks
    21
    Thanked 9 Times in 9 Posts
    Code:
    <?PHP
    switch($id) 
    {
    default:
    echo "this is the default page";
    case '4:
    echo "put '4' content here";
    break;
    break;
    }
    ?>
    Last edited by Rappa; 08-30-2006 at 05:59 AM.

  • #6
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    What? That is NOT an htaccess rewrite. If you missed the first post, i will repeat it.

    I want a user to be able to put articles/4.html in their browser and it to be parsed by the server as news.php?id=4

    I don't need to know how to display different material according to the id #. Using htaccess rewrite methods only, how do I do this?

  • #7
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    does anyone know how to do this?

  • #8
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    *bump*

  • #9
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you cant do that with .htacces try this though
    PHP Code:
    <?php
    $action 
    $_GET['page'];

    function 
    yourfilename() {
    include(
    "yourfilename");
    }
    if (
    $page == "yourfilename") {
    yourfilename();
    }
    ?>
    then you can make a link like index.php?page=yourfile
    and it will display you file on the page

  • #10
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    So why wouldn't something like this work?

    RewriteRule ^articles/(.*).html$ news.php?id=$1 [L]

    That should work but there is a syntax error in there somewhere and I don't know what is wrong.


    *edit*

    Actually, this does work. View: http://image-space.net/articles/4.html and http://image-space.net/profile/news.php?id=4
    Last edited by thesavior; 09-03-2006 at 12:05 AM.

  • #11
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you knew how to do it y post a thread onit?

  • #12
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Quote Originally Posted by googleit
    you cant do that with .htacces try this though
    yes, you can.

  • #13
    Regular Coder googleit's Avatar
    Join Date
    Jul 2006
    Location
    birmingham, uk
    Posts
    189
    Thanks
    0
    Thanked 0 Times in 0 Posts
    k my bad

  • #14
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post
    i just came up with that. I didn't know it at the begining of this thread

  • #15
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    the . probably needs to be escaped...


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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