简体   繁体   English

.htaccess重定向,MIME错误

[英].htaccess redirecting, MIME error

I'm trying to redirect URL like this 我正在尝试这样重定向URL

http://localhost/web/gallery/dogs

to

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

To do that, I try with the next .htaccess 为此,我尝试下一个.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>

I have the next problem, if I write the URL manually, it looks well with correct CSS and without errors. 我有下一个问题,如果我手动编写URL,那么在正确的CSS且没有错误的情况下看起来不错。 Else, if I use first URL, firefox give me MIME type error with CSS and other files, so, it appears like an old without colors web. 否则,如果我使用第一个URL,则firefox会为我提供CSS和其他文件的MIME类型错误,因此,它看起来像一个没有颜色的旧网络。

Nobody know how I can solve this? 没有人知道我该如何解决?

Thank you!! 谢谢!!

Edit: 编辑:

I'm trying now it online, and happen the same. 我现在正在网上尝试,并且发生了同样的事情。 I don't change anything. 我什么都没改变。

If I try this URL 如果我尝试这个网址

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

it goes well, else, trying this: 一切顺利,否则,请尝试以下操作:

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

it doesn't work properly 它不能正常工作

Sounds like you need to either make your CSS links absolute, so that they start with /web/ or add the relative URI base to the header of your page: 听起来您需要使CSS链接成为绝对链接,以便它们以/web/开头,或者将相对URI基添加到页面标题中:

<base href="/web/" />

Or if your URI base is just / (as it appears to be in your htaccess file), then: 或者,如果您的URI基础只是/ (似乎在您的htaccess文件中),则:

<base href="/" />

It seems your css file are being rewritten. 看来您的css文件正在被重写。

On your http://alexander.comyr.com/gallery/Historias_del_mar page, the CSS files redirect to http://alexander.comyr.com/gallery/css/foundation.css . 在您的http://alexander.comyr.com/gallery/Historias_del_mar页面上,CSS文件重定向到http://alexander.comyr.com/gallery/css/foundation.css They should be going to http://alexander.comyr.com/css/foundation.css 他们应该去http://alexander.comyr.com/css/foundation.css

So I would try exluding CSS files from your rewrites, like adding the following condition to your rules: 因此,我将尝试从您的重写中删除CSS文件,例如将以下条件添加到您的规则中:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM