htaccess重写后的“意外令牌'>'”第1行(css和图像中断)

Joa*_*edt 5 php .htaccess multilingual content-management-system kirby

基本上,我一直打算做的是修复损坏的链接。旧链接可能指向http://www.example.com/work/funkystuff,我正在将其重定向到http://www.example.com/en/work/funkystuff

因此,这是这种可怕疾病的症状:

  1. 图片,CSS和Java脚本中断。控制台会告诉我Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/en/".每种类型的“ ”。

  2. 我在文档类型所在的文件的第一Uncaught SyntaxError: Unexpected token <行收到有关“ ” 的奇怪错误index.php。这使我认为它甚至没有将我的.php文档解释为.php文档...

从我在Google会话中收集到的信息来看,这不应该发生。我的链接是绝对的(由php回显),并且我有RewriteCond仅重定向不存在的文件和目录(第4和第5行)。

是的,这就是我的.htaccess的样子。

# enable awesome urls. i.e.: 
# http://example.com/about-us/team
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links will break.
# 
# If your homepage is http://example.com/mysite
# Set the RewriteBase to:
# 
# RewriteBase /mysite
# 
RewriteBase /

# Redirect key areas of the site before localisation.
RewriteRule ^work/(.*)$ /en/work/$1 [NC,R=301,L]
RewriteRule ^news/(.*)$ /en/news/$1 [NC,R=301,L]
RewriteRule ^about/(.*)$ /en/about/$1 [NC,R=301,L]
RewriteRule ^careers/(.*)$ /en/careers/$1 [NC,R=301,L]
RewriteRule ^contact/(.*)$ /en/contact/$1 [NC,R=301,L]
RewriteRule ^update-twitter/(.*)$ /en/update-twitter/$1 [NC,R=301,L]

# redirect everything to index.php
RewriteRule ^(.*) index.php [L]
Run Code Online (Sandbox Code Playgroud)

我希望有人知道这可能是什么,因为我很糊涂。

编辑:我觉得我应该添加一些更多的信息。

我们正在使用一个名为Kirby的CMS,现在开始转移到该网站的多语言版本。通过自动检测浏览器语言并将用户从域重定向到域/语言,Kirby可以为我们轻松地做到这一点。

事实是,我们通过使用重定向使事情变得复杂。URL的语言部分不是真正的子目录,而是名称。

Wig*_*ige 0

要修复 css MIME 类型,请将以下行添加到 htaccess 文件中:

AddType text/css .css
Run Code Online (Sandbox Code Playgroud)

这假设样式表文件名以 .css 结尾。如果没有,请更改它。