0

这是我的重写规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
#RewriteRule (.*)/?$ $1\.php [L]
RewriteRule profile/ profile.php
RewriteRule profile profile.php

我对此有点陌生,但是当我转到 localhost/profile 时,一切正常,但是当我转到 localhost/profile/ 时,实际页面加载,但 css 没有加载,我必须手动将其更改为/style.css 来加载它,有谁知道我怎么能做到这一点,同时使 / 在最后是可选的(不必放置我的整个域或绝对路径)?谢谢。

4

1 回答 1

1

you can Try this <? echo '<link rel="stylesheet" type="text/css" href="'."http://".$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']."../style.css".'" />' ?>

But this is not the best solution. What you can do is you can define a global variable use that to give absoluete paths. i.e

<?php 
//at the beginning of your page
define('LINK',"http://localhost/");

//for your css href
echo LINK."style.css";

Note: The path is assumption as i do not know your folder structure.

于 2012-12-24T05:32:46.443 回答