[htaccess]Index.php GET Variables [HELP]

Status
Not open for further replies.

Legion

Gaming Lord
Staff member
Nov 23, 2011
1,808
679
Hey guys,

Need a little .htaccess help. So, I have this site
mysite.com/game.php
and I want to get it to
mysite.com/index.php?page=game

Anyone know the code to be able to do this :s
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
You don't need .htaccess for that.

You could just do something like..

PHP:
<?php
$page = strtolower($_GET["page"]);
 
if ($page == "home" || $page == "")
{
    echo "home page content";
}
elseif ($page == "about")
{
    echo "about page content";
}
elseif ($page == "games")
{
    echo "Games page content";
}
else
{
    echo "404 page not found";
}
?>
 

Legion

Gaming Lord
Staff member
Nov 23, 2011
1,808
679
You don't need .htaccess for that.

You could just do something like..

PHP:
<?php
$page = strtolower($_GET["page"]);
 
if ($page == "home" || $page == "")
{
    echo "home page content";
}
elseif ($page == "about")
{
    echo "about page content";
}
elseif ($page == "games")
{
    echo "Games page content";
}
else
{
    echo "404 page not found";
}
?>
Uh, I am stupid with PHP, I just want the htaccess code to make it :/
 

Tronscript

Member
Aug 18, 2012
93
8
PHP:
<?php
$page = strtolower($_GET["page"]);
 
if ($page == "home" || $page == "")
{
    require('home.php');
}
elseif ($page == "about")
{
    require('about.php');
}
elseif ($page == "games")
{
    require('games.php');
}
else
{
    echo "404 page not found";
}
?>
 

Legion

Gaming Lord
Staff member
Nov 23, 2011
1,808
679
PHP:
<?php
$page = strtolower($_GET["page"]);
 
if ($page == "home" || $page == "")
{
    require('home.php');
}
elseif ($page == "about")
{
    require('about.php');
}
elseif ($page == "games")
{
    require('games.php');
}
else
{
    echo "404 page not found";
}
?>
And would I put this in an empty index page or what? :confused: :/
 
Status
Not open for further replies.

Users who are viewing this thread

Top