努力创造清洁的URL时,CSS在前看不见 [英] css disapears when trying to create clean url's

查看:237
本文介绍了努力创造清洁的URL时,CSS在前看不见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图推行清洁网址到我的网站,但我拼命地跑了一个问题。当我试图加载只是默认网址feks:www.example.com,一切正常,因为它应该,但是当我试图改变这样的:www.example.com/home/,一切加载,除了我的图片和我的CSS。

只是一些测试HTML:

 < HTML>
  < HEAD>
    <元的charset =UTF-8>
    <冠军>< /标题>
    <链接HREF =css.css相对=样式类型=文本/ CSS>
  < /头>
  <身体GT;
     < P>只是一个例子文字< / P>
  < /身体GT;
< / HTML>
 

我的htaccess文件:

 < IfModule mod_rewrite.c>
  RewriteEngine叙述上
  的RewriteCond%{} REQUEST_FILENAME!-f
  的RewriteCond%{} REQUEST_FILENAME!-d
  重写规则^的index.php [L]
 < / IfModule>
 

解决方案

您必须使用绝对链接:

 <链接HREF =htt​​p://www.example.com/css.css相对=样式类型=文本/ CSS>
 

或添加在< HEAD>

 <基地的HREF =htt​​p://www.example.com/>
 

 <基地的HREF =/>
 

I'm trying to implement clean url's to my website, but I've runned into a problem. When i'm trying to load just the default url feks: www.example.com, everything works as it should, but when i try changing it like this: www.example.com/home/, everything loads except my images and my css.

Just some testing html:

<html>
  <head>
    <meta charset="UTF-8">
    <title></title>
    <link href="css.css" rel="stylesheet" type="text/css">
  </head>
  <body>
     <p>just an example text</p>
  </body>
</html>

My htaccess file:

 <IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^ index.php [L]
 </IfModule>

解决方案

You must use absolute links:

<link href="http://www.example.com/css.css" rel="stylesheet" type="text/css">

or add in the <head>:

 <base href="http://www.example.com/">

or

 <base href="/">

这篇关于努力创造清洁的URL时,CSS在前看不见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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