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 !!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.