Computer ForumsComputers  

Go Back   Computer Forums > Programmers Lounge > Programming Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 12-06-2006, 05:10 AM   #1 (permalink)
Phx
Newb Techie
 
Join Date: Nov 2006
Posts: 27
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   Reply With Quote
Reply

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



All times are GMT -5. The time now is 08:08 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0