【问题标题】:css in codeigniter代码点火器中的 css
【发布时间】:2012-08-06 19:41:40
【问题描述】:

您好,我在 codeigniter 中遇到了这样的问题。我无法使用 .css 文件的样式。但我知道这个过滤器与我的观点有关。 (萤火虫)。这是我的连接链接:

`<link rel="stylesheet" href="images/Enlighten.css" type="text/css" />`

/images/Enlighten.css目录下的css文件

这是我的 htaccess 文件:

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|template|robots\.txt|public|)
RewriteCond %{REQUEST_URI} !\.(css¦js¦jpg¦gif)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]

我认为我的错误在这个文件中。(我不处理这个文件:(()

P.S Everywhere 当我使用来自 Enlighten.css 的样式时,文本打印为 '??????????'

【问题讨论】:

  • 抱歉,我已将文本标记为代码,因为网站无法区分文本中的代码
  • 不用担心。我为你修好了。对于代码,您可以使用 4 个空格而不是 `

标签: css .htaccess codeigniter text view


【解决方案1】:
【解决方案2】:

为您的 htaccess 文件使用以下代码:-

<IfModule mod_rewrite.c>
    RewriteEngine on

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

【讨论】:

  • 我认为你在这里漏掉了一行 Rakesh。这样,所有内容都将被重定向到 index.php,包括 CSS 文件。
【解决方案3】:

我建议使用以下.htaccess

AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Prevents user access to the application folder
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule> 

【讨论】:

  • 恕我直言,这里没有必要限制访问,因为这些文件夹已经有自己的 .htaccess 文件,可以防止任何人访问它们。
  • @Robert 为什么要用空的index.html.htaccess 等不必要的文件阻塞文件系统?
  • 因此您不必将所有内容都放在一个文件中并在重命名文件夹时对其进行维护。
  • @Robert 但这只是一般访问权限。我认为,在一个.htaccess 文件中检查哪些文件和目录是公开的更容易,而不是检查每个子目录中的所有文件。也许,这只是我个人的喜好。 :)
猜你喜欢
  • 2012-02-09
  • 1970-01-01
  • 2018-11-24
  • 1970-01-01
  • 2011-06-04
  • 2016-01-28
  • 2012-06-30
  • 2012-02-21
  • 2011-03-29
相关资源
最近更新 更多