重写引擎。htaccess的MIME类型的错误 [英] Rewrite Engine .htaccess MIME type error

查看:146
本文介绍了重写引擎。htaccess的MIME类型的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,使搜索我想要的结果也与查询访问

I have a script that make search and I want the results also be accessible with query

mysite.com/searchfor/"myword"

我说后面的行为.htaccess:

I added next lines to .htaccess:

RewriteEngine on
RewriteRule  ^/?searchfor/(.*)$ search.php?search=$1 [L]

它的工作原理(加载页面时),但每一个链接的资源(CSS / JS)加载失败与下一个错误:

It works (the page is loading), but every linked resource (css/js) failed to load with next error:

Resource interpreted as Stylesheet but transferred with MIME type text/html
Resource interpreted as Script but transferred with MIME type text/html:

这些线参阅mysite.com/searchfor/theme.css~~V,但它是错误的,因为右链接到的CSS是mysite.com/theme.css

These lines refer to mysite.com/searchfor/theme.css, but it is wrong, as the right link to the css is mysite.com/theme.css.

我怀疑RewriteEngine叙述给错了路加载样式和脚本是什么失败了。 如何解决此问题?

I suspect RewriteEngine giving wrong path to load styles and scripts what failed it. How to solve this?

推荐答案

试试这个规则:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule ^/?searchfor/(.+)$ search.php?search=$1 [L]

这篇关于重写引擎。htaccess的MIME类型的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆