【问题标题】:.htaccess redirecting, MIME error.htaccess 重定向,MIME 错误
【发布时间】:2014-04-23 08:11:16
【问题描述】:

我正在尝试像这样重定向 URL

http://localhost/web/gallery/dogs

http://localhost/web/index.php?section=gallery&name=dogs

为此,我尝试使用下一个 .htaccess

RewriteBase /

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^gallery/(.*)$ index.php/?section=gallery&name=$1 [NC,L]

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

</IfModule>

我有下一个问题,如果我手动编写 URL,它看起来很好,并且 CSS 正确且没有错误。否则,如果我使用第一个 URL,firefox 会给我 CSS 和其他文件的 MIME 类型错误,所以,它看起来就像一个没有颜色的旧网页。

没有人知道我该如何解决这个问题?

谢谢!!

编辑:

我现在正在网上尝试,结果也是一样。我什么都没改变。

如果我尝试这个网址

http://alexander.comyr.com/gallery&name=Historias_del_mar

一切顺利,否则,试试这个:

http://alexander.comyr.com/gallery/Historias_del_mar

它不能正常工作

【问题讨论】:

    标签: php css .htaccess redirect mime


    【解决方案1】:

    您的 css 文件似乎正在被重写。

    在您的 http://alexander.comyr.com/gallery/Historias_del_mar 页面上,CSS 文件重定向到 http://alexander.comyr.com/gallery/css/foundation.css。他们应该去http://alexander.comyr.com/css/foundation.css

    所以我会尝试从您的重写中排除 CSS 文件,例如在您的规则中添加以下条件:

    ReWriteCond %{REQUEST_URI} !^.*\.css$
    

    【讨论】:

      【解决方案2】:

      听起来您需要将 CSS 链接设为绝对链接,以便它们以 /web/ 开头,或者将相对 URI 基础添加到页面标题:

      <base href="/web/" />
      

      或者,如果您的 URI 基础只是 /(因为它似乎在您的 htaccess 文件中),那么:

      <base href="/" />
      

      【讨论】:

        猜你喜欢
        • 2010-11-18
        • 1970-01-01
        • 2012-03-04
        • 2020-02-15
        • 1970-01-01
        • 2011-08-31
        • 2011-07-07
        • 2016-07-01
        • 1970-01-01
        相关资源
        最近更新 更多