我需要我的 .htaccess file ....现在我有链接,如http://www.afrogfx.com/2012102805053/test.htest.html带有 slash/的问题!如果您单击我的链接,您将发现无样式的链接,如果删除斜线,您将无法找到404,例如http://www.afrogfx.com/20121028050853Test.html尝试一下 !!这是我的.htaccess
RewriteEngine On
RewriteRule ^([a-zA-Z0-9-/]+).html$ readmore.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+).html/$ readmore.php?url=$1
readmore.php
<?php
include ('config/connect_to_mysql.php');
$url=$_GET['url'];
if($_GET['url'])
{
$url=mysql_real_escape_string($_GET['url']);
$url=$url.'.html'; //Friendly URL
$sql=mysql_query("select * from posts where url='$url'");
$count=mysql_num_rows($sql);
$row=mysql_fetch_array($sql);
$title=$row['title'];
$text=$row['text'];
}
else
{
echo '404 Page.';
}
?>
问题在这里
<?php
include('styles/header.php');
include ('styles/leftblock.php');
include ('styles/mrnuleft.php');
?>
<?php
if($count)
{
echo "<h1>$title</h1><div class='text'>$text</div>";
}
else
{
echo "<h1>404 Page.</h1>";
}
?>
我认为问题是一个路径问题。当我带着斜线进入页面时,其中包括:
styles/assets/css/bootstrap.css
因此,它实际上要包含的是:
http://www.afrogfx.com/20121028050853/styles/assets/css/bootstrap.css
尝试告诉它从根目录加载:
/styles/assets/css/bootstrap.css
您可以使所有标题链接绝对:
来自:
<link href="styles/assets/css/bootstrap.css" rel="stylesheet">
to:
<link href="/styles/assets/css/bootstrap.css" rel="stylesheet">
或者您可以在<head>
标签下方添加:
<base href="/">
问题是您具有针对样式和脚本的相对链接。当浏览器试图请求之类的内容:/20121028050853Test.html
时, uri base 就是/
。但是,当浏览器请求/20121028050853/Test.html
时,基数将变为/20121028050853/
,并且浏览器将使用此基础并将所有相对URL附加到此基础上,因此styles/assets/css/bootstrap.css
变为/20121028050853/styles/assets/css/bootstrap.css
,您没有样式或脚本。