努力创造清洁的URL时,CSS在前看不见在前、清洁、努力、URL

2023-09-02 00:46:47 作者:肆意失声痛哭

我试图推行清洁网址到我的网站,但我拼命地跑了一个问题。当我试图加载只是默认网址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="/">