Jump to content

Mod_rewrite multiple vars with php include layout?


Lukeidiot

Recommended Posts

I have a layout (heres the code) that includes .php files into the index.php file.

<?php
// PHP Navigation -----------------------
$go = $_GET['go'];// Gets the ?go
$fd = $_GET['fd'];// Gets the ?fd
if(empty($go))// If go is empty
{
$go = 'main.php';// Includes the default page
}
// Cleaning the gets --------------------
$go = str_replace('http://','',$go);
$go = str_replace('www.','',$go);
$go = str_replace('.php','',$go);
$go = str_replace('.txt','',$go);
$fd = str_replace('http://','',$fd);
$fd = str_replace('www.','',$fd);
$fd = str_replace('.php','',$fd);
// End of Cleaning the gets ---------------
if(isset($fd) && isset($go) && file_exists($fd."/".$go.".php")){
include ($fd."/".$go.".php");
}else if(isset($go) && file_exists($go.".php")){
include ($go.".php");
}else{
echo "<p><b>Sorry, that page does not exist.</b></p>";
}
// End of PHP Navigation ----------------- 
?>

 

I am trying to make it where I can navigate through my blog by visiting this url:

http://www.lukeidiot.com/blog/29

 

by actually redirects to this url:

http://www.lukeidiot.com/?go=blog&id=29

 

I was using this for my .htaccess

ReWriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?go=$1 [QSA,L]

 

I was exploding the $_GET['go'] by "/"

 

and using it as such, but it didn't include correctly. I tried for hours but couldn't get it to work.

 

(NOTE MY MOD_REWRITE DOESNT WORK)

 

Thanks !!!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.