Jump to content

URL not displaying correctly


chrisguk

Recommended Posts

Hi,

 

I think my problem is a mixture of MODREWRITE and PHP.

 

I have the following .htaccess located in the web root.

 

RewriteEngine On
RewriteRule ^about/(([^/]+/)*[^/.]+)$ /about/index.php?p=$1 [L]             
RewriteRule ^(([^/]+/)*[^/.]+)$ index.php?p=$1 [L]

 

The index.php example below is located in the folder "about".  Just for your info I also have an index at the web root too serving other files.

 

<?php 
$page = isset($_GET['p']) ? $_GET['p'] : '/about/about'; 

switch($page) { 
/*----------------------- PAGES -----------------------------------*/ 

case 'about/profiles': 
$title = 'My Title'; 
$keyword = 'A few keywords'; 
$description = 'A good description.'; 
break; 

default:
$title = 'My Title'; 
$keyword = 'A few keywords'; 
$description = 'A good description.'; 
break; 
}
include($_SERVER['DOCUMENT_ROOT']. '/include/header.php');  

include($_SERVER['DOCUMENT_ROOT']. 'about/'.$page.'.php');

include($_SERVER['DOCUMENT_ROOT']. "/include/footer.php");

?>

 

This is my problem: 

 

When I click on the link http://mysite.co.uk/about/ it throws the errors out below. 

 

When I click on the link http://mysite.co.uk/about/profiles/ it works fine and for the life of me I cant understand what I have done wrong.

 

Warning: include(/var/www/mysite/about//about/about.php) [function.include]: failed to open stream: No such file or directory in /var/www/mysite/about/index.php on line 22

Warning: include() [function.include]: Failed opening '/var/www/mysite/about//about/about.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mysite/about/index.php on line 22

 

I am a kinda of newbie so any help/guidance will be gratefully received :)

 

Link to comment
https://forums.phpfreaks.com/topic/261102-url-not-displaying-correctly/
Share on other sites

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.