Nice URL's problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ellesgaard
Forum Newbie
Posts: 2
Joined: Tue Jul 27, 2010 2:22 am
Location: Sønderborg, Denmark

Nice URL's problem

Post by ellesgaard »

Hi there.
I have a problem, with my nice URL script.
It kind of works. The address 'muoa2/account' works fine, but if I add a / to end like 'muoa2/account/' or 'muoa2/account/5', my css disapears :?

The .htaccess code:

Code: Select all

Options +FollowSymLinks  
RewriteEngine On  
  
RewriteCond %{SCRIPT_FILENAME} !-d  
RewriteCond %{SCRIPT_FILENAME} !-f  
  
RewriteRule ^.*$ ./index.php
And my index.php code:

Code: Select all

$request  = str_replace("/muoa2/", "", $_SERVER['REQUEST_URI']); 
$params     = split("/", $request);

$design = "design1";

$mappe = "dash/";
$side = "index";

if ($params[1] !=""){
	$side = $params[1];
}
if ($params[0] !=""){
	$mappe = $params[0] . "/";
}

#echo $mappe;
#echo "<br>pages/" . $mappe . $side . ".php";

$page_content = file_get_contents("design/". $design . "/main.html");
$page_content = str_replace("!!HEADER!!", file_get_contents("design/" . $design . "/header.php"),$page_content);
$page_content = str_replace("!!MENU!!", file_get_contents("design/" . $design . "/left_column.php"),$page_content);
$page_content = str_replace("!!FOOTER!!", file_get_contents("design/" . $design . "/footer.php"),$page_content); 

if (file_exists("pages/" . $mappe . $side . ".php")) {
	$page_content = str_replace("!!INDHOLD!!", file_get_contents("pages/" . $mappe . $side . ".php"),$page_content);
} else {
	echo "404";
}

echo $page_content;
Anyone who can help with an idea?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Nice URL's problem

Post by Benjamin »

You can set the base url or use an absolute path to the css file.
ellesgaard
Forum Newbie
Posts: 2
Joined: Tue Jul 27, 2010 2:22 am
Location: Sønderborg, Denmark

Re: Nice URL's problem

Post by ellesgaard »

Thanks that solve the problem. :D
Post Reply