Mod 重写 - 错误链接

Mod Rewrite - wrong links

在 .htaccess 中我有:

RewriteEngine on
RewriteRule documentation documentation.php?id=0
RewriteRule documentation/process documentation.php?id=1

当我打开 https://example.com/documentation/process 时,调用了正确的网站 (documentation.php?id=1),但因为我有类似“assets/css/xxx.css”而不是“https”的链接://example.com/assets/css/xxx.css" 我的网站无法正常工作 - 基本上它指向了错误的目录。 如何在不更改所有链接到“https://example.com/assets/css/xxx.css”的情况下解决该问题?

像这样在两侧使用锚点,使用适当的标志并关闭 MultiViews

Options -MultiViews
RewriteEngine On

RewriteRule ^documentation/?$ documentation.php?id=0 [L,QSA,NC]
RewriteRule ^documentation/process/?$ documentation.php?id=1 [L,QSA,NC]

此外,您还必须将其添加到您网页 HTML 的 <head> 标记下方:

<base href="/" />

这样每个 亲戚 URL 都是从该基础 URL 解析的,而不是从当前页面的 URL.