friendly urls working, but not with a php $_REQUEST variable

Discuss practical ways rearrange URLs using mod_rewrite.

friendly urls working, but not with a php $_REQUEST variable

Postby rsleventhal » Thu Sep 30, 2010 7:39 am

Hi,

My current .htaccess file looks like this:

Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ /index.php?$1 [QSA,L]


Which works really well, given that I want friendly URLs

A bit of my document's php code which works with the .htaccess:
Code: Select all
$page = basename($_SERVER['QUERY_STRING']);
// this is an exception rule...if no token is passed, hand off the home page
if (!$page) {
    $pagename = 'content/home.php';
} else {
    if (file_exists('content/' . $page . '.php')) {
        $pagename = 'content/' . $page . ".php";
        $pagetitle = ucwords($page);
    } else { // if token is invalid, hand off a custom 404
        $page = '404';
        $pagename = 'content/404.php';
        $pagetitle = 'Oops...file not found';
    }
}

So, without anything after the url's last / (http://www.example.com/) I'm handing off 'home.php' from the '/content/' subfolder.
The rest of the index.php document calls in (using an include), the $pagename as the body of the main page (index.php).

I've got one page, lookup.php, which needs a php $_REQUEST value, so that a link to it will be: http://www.example.com/lookup?lookuptype=0

This gives me a 404 with the current setup and I'm entirely confused.
Any pointers or advice will be greatly appreciated.

Thanks in advance,
-Ray
rsleventhal
 
Posts: 15
Joined: Thu May 15, 2008 7:17 am

Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 20 guests

cron