Grow your CSS skills. Land your dream job.

Grab end or url (like domain.com/info) and use a var 4 index

  • # September 20, 2009 at 10:54 am

    Hi,

    I wanted to know if anyone new a way of grabbing the end of the url. What I would like is the normal "domain.com/index.php" then when you use a different url like "domain.com/info" the info will become a variable for the index page.

    Does anyone know how to do this or a tutorial that will help with this type of thing?

    # September 22, 2009 at 8:22 am

    put this in a .htaccess file:

    Code:
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?url=$1 [L]

    and put this in the index.php:

    Code:
    //url rewrite
    $url = strip_tags($_GET['url']);
    $url = explode(‘/’, $url);

    echo ‘

    ';
    print_r($url);
    echo '

    ‘;

    now all the stuff after the domainname is in the $url variable.

    # September 22, 2009 at 8:25 am

    Thanks so much! I will defiantly give this a try!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".