Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 12-06-2006, 06:10 AM   #1 (permalink)
Phx
 
Newb Techie

Join Date: Nov 2006

Posts: 27

Phx

Default PHP / mod_rewrite

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 ' . $id . '.php 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?
Phx is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On