我有以下PHP文件:
http://example.com/details.php?item=asdf
但是,我希望URL更简洁:
http://example.com/item/asdf/details
我试着用
.htaccess
文件类型:
RewriteEngine on
RewriteRule ^item/(\w+)/details$ details.php?item=$1
URL重写也可以。
但是,当我试图加载
main.css
居住在
http://example.com
从
details.php
,我从Chrome收到以下消息:
Failed to load resource: the server responded with a status of 404 (Not Found)
因为它找不到
http://example.com/asdf/main.css
.
是否有任何方法可以将原始URL的“base”或“root”目录与重写的URL一起使用?我想进入
主.css
从动态生成的
asdf
“目录”。我不想用
base
在HTML中标记,因为这看起来相当混乱,或者指向父目录,因为我使用的是模板页。
我试过了
RewriteBase /
但这只会造成另一个错误。有人能帮我吗?