【问题标题】:Can't access css file, htaccess无法访问css文件,htaccess
【发布时间】:2017-01-08 13:47:42
【问题描述】:

我添加了一个 .htaccess 文件来重定向一些请求,例如: /home/index 变成了 /index.php?controller=home&action=index&params=,但是那个 .htaccess 文件也阻止了我访问 /content/styles.css 文件。出于某种原因,我可以访问/content/images/default.png

Htaccess 内容:

Options +Indexes
Options -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.[^\/]+)\/(.[^\/]+)\/(.+)\/*$ index.php?controller=$1&action=$2&params=$3 [QSA,L]
RewriteRule ^(.[^\/]+)\/*$ index.php?controller=$1 [QSA,L]
RewriteRule ^(.[^\/]+)\/(.[^\/]+)\/*$ index.php?controller=$1&action=$2 [QSA,L]

它位于 public_html 目录中。

我尝试将另一个带有Options +Indexes 的.htaccess 添加到/content/ 目录,但没有任何变化。从/content/ 访问任何文件但没有/content/images/ 被阻止。

这个:<link rel="stylesheet" href="/content/styles.css" /> - 不起作用。 这:mysite.com/content/styles.css - 不起作用。 这个:mysite.com/content/images/default.png - 有效。

//编辑:

当我将/content/styles.css 移动到/content/styles/styles.css 时效果很好,但是这个配置有什么问题吗?

【问题讨论】:

    标签: html apache .htaccess


    【解决方案1】:

    在您要访问csspng 文件的页面中添加此标记。

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

    然后尝试访问该页面。

    【讨论】:

    • 这对我没有用,我已经将该行放在 public_html 的 index.php 和包含所有页面的 html 的 `layout.php' 中。可能是其他文件中的一些奇怪的 .htaccess 配置(网站由公司托管),尽管我没有找到。
    猜你喜欢
    • 1970-01-01
    • 2014-02-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-19
    • 2021-12-15
    • 2011-12-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多