[英].htaccess rewrite for passing parameters
I would like change my URL from 我想将我的网址从
www.example.com/collections.php?id=abc123
to www.example.com/collections/abc123
www.example.com/collections.php?id=abc123
到www.example.com/collections/abc123
I use .htaccess
like this: 我这样使用
.htaccess
:
Options -Indexes
RewriteEngine On
RewriteRule ^collections/(\w+)/?$ collections.php?id=$1 [QSA,L,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Now, when I type www.example.com/collections/abc123
in browser, my webpage shows without loading any css files or script. 现在,当我在浏览器中输入
www.example.com/collections/abc123
时,我的网页显示出来而没有加载任何CSS文件或脚本。 can someone point out what is missing ? 有人可以指出缺少的是什么吗?
Thanks a lot. 非常感谢。
Well, apparently you're using a relative path in referencing your scripts. 好吧,显然您在引用脚本时使用的是相对路径。 So, what's happening is your browser is attempting to fetch those resources wrongly because of that additional
/
in the url, causing it to think you navigated to a different directory. 因此,发生的事情是您的浏览器由于URL中的附加
/
试图错误地获取这些资源,从而导致浏览器认为您导航到了另一个目录。 What you could do here is specify absolute paths instead. 您在这里可以做的是改为指定绝对路径。
An example would be http://example.com/css/style.css
as opposed to /css/style.css
一个示例是
http://example.com/css/style.css
,而不是/css/style.css
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.