Forum Moderators: phranque
But the problem i have is that the compiler does not execute the external style sheet
from the Category.php, it just execute the internal style sheet in Category.php, when
i try to cretae a dynamic URL from the file of the Category.php.
Could any tell me why? and i have to use the internal style sheet?
i have tow files as following:
Index.php
<html>
<body>
<a href="Category.php"> go to Category file </a>
</body>
</html>
Category.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title> Welcome to my page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link rel="stylesheet" type="text/css" href="navlist.css" >
</head>
<body>
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="#" id="current">Home</a></li>
<li><a href="#">Contact Us </a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Help</a></li>
</ul>
</div><a href="/country/2/"> This is the link for the Url redirection testting </a>
</body>
</html>
when i click the link from the file of the Category.php, the compiler does not
execute the external style sheet, but it works for the internal style sheet.
if i use the following replace the external style sheet, the compiler will execute that:
<style type="text/css">
body
{
margin: 0;
padding: 0;
}
#navcontainer ul
{
text-align: center;
padding: 4px;
background-color: #0e10f6;
margin-left: 0;
margin-top: 5px;
width: 100%;
font-family: Arial, Helvetica, sans-serif;
line-height: 18px;
}#navcontainer ul li
{display: inline;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 0;
padding-right: 0;
}#navcontainer ul li a
{
border-right: 1px solid #fff;
padding-left: 10px;
padding-right: 10px;
padding-top: 5px;
padding-bottom: 5px;
color: white;
text-decoration: none;
}#navcontainer ul li a:hover
{
background-color: #09236c;
color: white;
}#navcontainer #active
{
border-left: 1px solid #fff;
}</style>
From a post yesterday:
[quot] ...it could "not work" because page-relative links on the pages being produced can't be properly resolved by the client, causing broken images, external CSS, and external JS links. Or it could be anything in between...
More on that: It is the client (browser or 'bot) that resolves page-relative links on pages. It does so using the current 'page' URL shown in the address bar. So, if you're rewriting those 'pages' on the server, the browser doesn't know that, and will request page-linked objects using the page address it knows about -- the one in the address bar. The two solutions are to either rewrite the object requests in addition to the page requests themselves, or to use server-relative or canonical URLs in the on-page object references. i.e. use <img src="/images/logo.gif> or <img src="http://example.com/images/logo.gif"> rather than <img src="images/logo.gif"> [/quote]
Jim
RewriteRule ^country/([0-9]+)/$ Category.php?page=$1 [L]
A solution could be to always rewrite to "Category.php", and have this script check its URL (it's still the one that you rewrote from) to decide what it has to do.
Unless I'm misunderstanding your point, that substitution URL-path is perfectly-valid; Apache supports passing query strings to scripts as so-called "GET parameters." After completing the rewrite and entering the content-handler API phase, Apache itself will ignore anything in the URL-path past the "?" and execute or serve the content from the file at the path preceding it -- In this case "Category.php".
The method you describe is also supported in at least two ways; The script itself can access and parse the requested URL-path, or --on Apache 2.0 and above-- you can use AcceptPathInfo and access the 'tail' of the requested URL-path (that part of the 'friendly' URL which does not actually exist) as the variable Path_Info from within the script.
The rewrite method demonstrated here is to be preferred if you cannot or do not wish to modify the script itself. But there are several methods available to suit the needs of individual sites and Webmasters.
Jim