的.htaccess不加载CSS和JS [英] .htaccess does not load css and js

查看:383
本文介绍了的.htaccess不加载CSS和JS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个博客文件,一个是 blogdetail.php bloglist.php 。我想说的是,如果有人在这样的链接进入。

I have 2 blog files one is blogdetail.php and bloglist.php. What i want to make is if someone enters on a link like this

http://mysite.com/blog

打开 bloglist.php 键,当有人进入到

http://mysite.com/blog/7

打开 blogdetail.php?ID = 7 。我的的.htaccess 到目前为止看起来像这样

to open blogdetail.php?id=7. My .htaccess so far looks like this

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^blog/([0-9]+)$ blogdetail.php?id=$1 [NC,L]
RewriteRule ^([a-zA-Z]+)$ $1.php [NC,L]
ErrorDocument 404 /404.php

但问题是,当我输入的博客/ 7 ,网页打开,但在CSS不加载。有没有一种方法,使这项工作,而无需使用绝对路径的CSS和JS? 谢谢你,大牛!

but the problem is when i enter on blog/7, the page opens but the css does not load. Is there a way to make this work without using absolute paths to css and js? Thank you, Daniel!

推荐答案

你错过了这个规则在.htaccess

you are missing this rules in .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/([0-9]+)$ blogdetail.php?id=$1 [NC,L]
RewriteRule ^([a-zA-Z]+)$ $1.php [NC,L]
ErrorDocument 404 /404.php

这篇关于的.htaccess不加载CSS和JS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆