我已经更改了我的网址
http://example.com/course.php?id=1001
到
http://example.com/course/1001
但在更改所有 css js 和图像的 url 后,它不起作用
我用过这段代码
RewriteEngine On
RewriteRule ^course/([A-Za-z0-9-]+)/?$ coursedetails.php?id=$1 [NC,L]
最佳答案
one solution is that use absolute path (ex /css, or /js rather than just css/, /js but this is not looks a reliable solution since we've to change it on all files,
这是因为您的相对 URI 的基础已更改。最初,基数是 /
当页面为 /course.php?id=1001
, 并且浏览器正确填写了带有 /
的相关链接根据。但是当浏览器转到类似 /course/1001
的页面时基地突然变成/course/
它会尝试将其附加到所有相对 URL 的前面,因此它们都不会加载。
您可以使您的链接成为绝对链接,或者更改您页面标题中的 URI 基础(在 <head> </head>
标记之间):
<base href="/">
关于html - 使用 mod_rewrite 后,我的 css imges js 路径发生了变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31212900/