0

我有一个 .htaccess 文件,它重定向到正确的 php 文件:

Options -Indexes

RewriteEngine on
RewriteOptions MaxRedirects=1
RewriteCond %{REQUEST_FILENAME} -f [NC,OR] 
RewriteCond %{REQUEST_FILENAME} -d [NC] 
RewriteRule .* - [L]
RewriteRule ^(.*)$ read.php/$1 [QSA,L]

例如mysite.com/post/100重定向到mysite.com/post/read.php ,我可以在我的 PHP 文件中使用 100 作为标识符。

这一切都很好,直到我使用mysite.com/post/100/or mysite.com/post/100/abc。该文件仍在被重定向,但我所有的 css 文件和包含()都不起作用。

<link rel="stylesheet" href="../styles/site.css" type="text/css">

该服务器将向上映射,因此包含不再起作用。

有什么解决办法吗?在这种情况下,使用http://www.mysite.com/styles/site.css不是解决方案。

4

1 回答 1

1

使用绝对路径,例如

<link rel="stylesheet" href="/styles/site.css" type="text/css">
于 2013-10-21T12:51:30.243 回答