我的 .htaccess 中有这个:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule . /index.php
这就是我使用参数的方式:
<?php
$request = $_SERVER['REQUEST_URI'];
$request = substr($request,1);
$params = explode('/', $request);
$safe_pages = array('page1','page2','page3');
if(in_array($params[0],$safe_pages))
{
include($params[0].'.php');
}else
{
include('404.php');
}
?>
假设我的网站是:www.site.com
www.site.com/page -> 完美运行
www.site.com/page/parameter -> 不加载任何 CSS 或图像,因为它在 root/page 而不是 root/ 中查找它们
我尝试对我的 css 和图像使用绝对链接,但它仍然不起作用,所以我猜问题出在 .htaccess 中,或者我遗漏了一些东西。