Babel and broken links

Really new to programming and also MODX. (so please don’t be too harsh :D)

I got a working website with babel installed, two languages. (de + en)
English is the main language.
When I insert a picture or video inside of the second language pages it won’t show the image on the website.
The link of the image returns to be “www.lorem.de/de/image
But it should be “www.lorem.de/image

Any idea where I can find the problem?

Thank you in advance.

I believe the base_url context setting is used (in some setups) to differentiate between the contexts. This works ok for the page links but generates wrong paths for static files.

I’ve seen cases where people fixed this with a RewriteRule in .htaccess.
Something like this may work (if your static files are in the “assets” folder).

# redirect all requests to /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(en|de)/assets(.*)$ assets$2 [L,QSA]

Thank you @halftrainedharry for the quick reply.

That’s a good hint and i looked into the .htaccess file.
I got something similar there:

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Scared to change it on a running Website. :grimacing:
It seems to be essential to have the “index.php” RewriteRule still in the script.

Yes, don’t change this. These lines are necessary for MODX to work with friendly URLs.


But you could add other RewriteRules above these lines.

1 Like

Was just scared to break the actual website. :smiley:

But now it’s working!
Thank you so much @halftrainedharry

For the record:

What did not work was:

# redirect all requests to /assets*
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /de/assets(.*)$ assets$2 [L,QSA]

Shouldn’t it be
RewriteRule /de/assets(.*)$ assets$1 [L,QSA]
if you removed the first pair of brackets?

Sorry for the late reply.
Yeah, that should be working, too.

But I used your suggestion and now i am happy. :smiley:

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.