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.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with html url

    Hi, what I want to do is to be able to take information from a requested url and use it to display a web page. For example, lets say I enter in the url www.mysite.com/hello.html. even though the file hello.html does not exist on my server, I want a web page to be displayed that uses the word given in the requested url in it. This way I would be able to have a page customized to say anything that is requested. I know this can be done somehow because i see it used all the time. Hope you understand what I am asking. Thanks!

  • #2
    New to the CF scene
    Join Date
    May 2009
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?php

    echo $_SERVER[REQUEST_URI];

    ?>

  • #3
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by developoor View Post
    <?php

    echo $_SERVER[REQUEST_URI];

    ?>
    Thanks, but when i use this it gives me the slash before the file name i.e. "/hello". is there anyway to not have the slash returned?

  • #4
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    Give this a shot...

    PHP Code:
    <?php
    echo substr($_SERVER['REQUEST_URI'],1] )
    ?>
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #5
    New Coder
    Join Date
    May 2009
    Posts
    55
    Thanks
    1
    Thanked 4 Times in 4 Posts
    A much better way to do that is using a simple php page. The urls should be like:

    index.php?page=home

    and then the selection of the file to show is done like:


    switch($page)
    {
    case 'register': break;
    default:
    $page = 'home';
    }

    include("$page.php");


  •  

    Tags for this Thread

    Posting Permissions

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