the code below sets $number to anyting that is after the/ of of my domain. i wonder how i can make it so that if there is nothing after the / $number automaticlly is set to 1. $number = basename('http://'.$_SERVER['HTTP_HOST'].($_SERVER['REQUEST_URI'] == '/' ? 1 : $_SERVER['REQUEST_URI']));
well, that works kinda. what i want is so that if my url is for example http://mydomain.com/2 $number becomes 2 and so on, however if there is nothing behind the / $number becomes 1.
It'll try to load a directory if it's a /1 or /2 etc.. You will need some .htaccess to redirect it to a php file to handle it.
$number = (is_numeric(basename($_SERVER['REQUEST_URI']))) ? basename($_SERVER['REQUEST_URI']) : 1; PHP:
It goes in your .htaccess file like this: RewriteEngine ON RewriteRule ^([0-9]+)$ index.php?number=$1 [L]