So i have a standard file located at:
/sites/default/files/hello.png
I can access it like so:
http://www.example.com/sites/default/files/hello.png
However, with i18n, it would be nice if the prefixed paths would also work for these files. For example, this link doesn't work:
http://www.example.com/us/sites/default/files/hello.png
But it doesn't.
So my question is, how can I make these "country-specific" paths also work for files?
I am thinking I might need to do something in htaccess and then also create a module that filters and redirects these paths, but that just sounds like way too much effort and that perhaps I am missing the easy way to enable this?
You can use htaccess to make all language-version URLs redirect to the default URL for files/images. If you do this you won't need to do anything further in your drupal code (e.g. a custom module).
Your rewrite rule would look like this
RewriteEngine On
RewriteRule ^([a-zA-Z-]*)/sites/default/files/(.*)$ sites/default/files/$2 [R=301,L]
Updated
If your site is in a subdirectory e.g. 'drupal', you could modify your rewrite rule like this
RewriteRule ^drupal/([a-zA-Z-]*)/sites/default/files/(.*)$ drupal/sites/default/files/$2 [R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With