7

Basically, what I've been aiming at doing is to fix broken links. Old links might point to http://www.example.com/work/funkystuff, and I'm redirecting them to go to http://www.example.com/en/work/funkystuff.

So here are the symptoms of this horrible disease:

  1. Images, Css & Javascript breaks. The console tells me "Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost/en/"." for each type.

  2. I get the weird error about "Uncaught SyntaxError: Unexpected token <" on line one of my index.php files, where my doctype is. This leads me to think that it's not even interpreting my .php document as a .php document...

From what I've gathered from my Google sessions, this shouldn't be happening. My links are absolute (echoed out by php), and I have the RewriteCond to only redirect non-existing files & directories (line 4 & 5).

So yeah, this is what my .htaccess looks like.

# 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]

I hope someone knows what this might be, because I'm confused as hell.

EDIT: I feel that I should add some more information.

We're using a CMS called Kirby and are now starting to move over to a multi-language version of the site. Kirby can do this for us simply, by auto-detecting browser language and redirecting users from domain to domain/language.

The thing is that we're complicating things by using redirects. The language part of the URL isn't a real subdirectory, but rather a name.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Joakim Wimmerstedt
  • 709
  • 1
  • 10
  • 28

1 Answers1

0

To fix the css MIME type, add the following line to your htaccess file:

AddType text/css .css

This assumes that the stylesheet filename ends with .css. If it doesn't, change it.

Wige
  • 3,788
  • 8
  • 37
  • 58