Web Hosting Talk







View Full Version : User Friendly URL's


BaZaRRe
01-29-2005, 03:45 AM
I was wondering how I could use ModRewrite to communicate with a PHP script which will display a file included by that php script. So that instead of index.php?pagename=something its /something.... Also so that if there is a way of index.php?pagename=something?act=something using the following function:

function load_code($act, $act2) {
global $config, $db, $user;

if (!file_exists("$config->files_directory/$act/$act2.php")) {
error("normal", "The requested page was not found.");
}
return "$config->files_directory/$act/$act2";
}

Modify it in any way to work, i just need help ;)

Kyndig
01-29-2005, 11:46 PM
Why go through all the hastle of using a server-required mod_rewrite rule (though it isn't too difficult...for those without root acces, its a pain )

What I do to pass variables, and make my urls spider friendly is

create a page, call it: test.php

Visit:
http://yoursite.com/test/foobar

$arg = explode( "/", getenv('PATH_INFO') );
if( empty( $arg[1] ) )
{
echo "Nothing was passed";
}
else
{
echo $arg[1];
}

Vioula..the rest you can figure out

The only thing that then needs to be changed in your webserver setting (if using apache) is the <Directory /> statement to read something like:
<Directory />
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
AllowOverride None
</Directory>