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:
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.I get the weird error about "
Uncaught SyntaxError: Unexpected token <
" on line one of myindex.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.