我有一个网站正在运行,localhost/pm并且 RewriteBase 正确设置为/pm/. 我的文档中有一个链接标签:<link ... href="themes/default/css/default.css">.
当 urllocalhost/pm或localhost/pm/fooCSS 工作正常时。但是,当 URL 中有更多斜杠时,例如localhost/pm/foo/bar样式表更改为foo/themes/default/css/default.css.
我如何让它工作而不必在链接标签中放置某种 PHP 路径解析?
# invoke rewrite engine
RewriteEngine On
RewriteBase /pm/
# Protect application and system files from being viewed
RewriteRule ^(?:system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
编辑:
基本上我现在需要的是:如果请求包含文件夹名称/themes/,则废弃之前的所有内容/themes/并将其余部分重写为/pm/themes/...
我像这样尝试过:RewriteRule ^.*(/themes/.*)$ /pm/themes/$1但我得到一个内部服务器错误。为什么?
如果我这样做:(RewriteRule ^.*(/themes/.*)$ /pm/themes/即,只需从末尾删除 $1 )并使用 URLhttp://localhost/pm/foo/themes/foo/生成的物理位置http://localhost/pm/themes也是预期的,这反过来意味着至少我的正则表达式是正确的。我错过了什么?