我的 .htaccess 文件出错:/

发布于 2025-01-06 22:08:19 字数 1331 浏览 2 评论 0原文

我正在开发一个小型网站,我想使用 .htaccess 文件使我的 URI 对搜索引擎更加友好。我的问题是,找不到我的 CSS 文件。我使用以下 .htaccess 规则:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

也许你们很多人都知道这段代码。我的网站结构如下:

/
-css
 -layout.css
-images
 -image.jpg
-js
 -jquery.js
-includes
 -controller
 -model
 -view
-.htaccess
-index.php

当我加载网站时,CSS 部分未加载。我的模板如下所示:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title><?php echo $this->title ? $this->title : 'MVC Beispiel'; ?></title>
        <link href="css/layout.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    $content
    </body>
</html>

我尝试了不同的方法。以下代码不应该停止模块来重写对 css 文件的请求吗:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} (\.css)$
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

如果您能帮助我找到解决方案,我将非常高兴。 :/ 提前致谢。

I'm developing a small website and i want to use a .htaccess file to make my URIs more search engine friendly. My problem is, that my CSS files can't be find. I use the following .htaccess rules:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

Maybe many of you know this code. My website stucture is the following:

/
-css
 -layout.css
-images
 -image.jpg
-js
 -jquery.js
-includes
 -controller
 -model
 -view
-.htaccess
-index.php

When I load my website, the css parts are not loading. My template looks like this:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title><?php echo $this->title ? $this->title : 'MVC Beispiel'; ?></title>
        <link href="css/layout.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    $content
    </body>
</html>

I tried different ways. Shouldn't the following code stop the module to rewrite the request for css files:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} (\.css)$
RewriteRule ^.*$ - [NC,L]

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ /index.php [NC,L]

It would be really glad, if you could help me, to find a solution. :/ Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文