PHP / mod_rewrite

Status
Not open for further replies.

Phx

Baseband Member
Messages
27
Ok guys. Need some help with this.

I have URLs like the following:
index.php?id=page page is page.php

I have it so bare pages are included with php into the index.php, which then has the css there so the page looks normal

index.php:
Code:
<?PHP 
$id = $_GET['id']; if (!isset($id)) { $id = 'home'; } 
if (strstr($id,'/')) { $id = 'no'; } 
if (!file_exists($id . '.php')) { 
echo('404 [b]' . $id . '.php[/b] could not be found!'); 
} 
else { 
include($id . '.php'); 
} 
?>

I want URL's like domain.com/id/page, and here's how you would do it would mod_rewrite:
Code:
RewriteEngine on
RewriteRule ^id/([^/\.]+)/?$ index.php?id=$1 [L]

However, it REDIRECTS, it doesn't INCLUDE, like I need it to.

So, without putting all the code on each content page, how would I get this working correctly?
 
Status
Not open for further replies.
Back
Top Bottom