1

I have a drupal installation in a sub folder (demos/drupal) and it supports two languages (english -default- & arabic). I imported the drupal content from an old site. My problem is that the language prefix (i.e. en or ar) is added to the url of all images and this causes the images to not appear. for example: http://www.mysite.com/demos/drupal/en/sites/default/files/image.png).

Can I remove the 'en' and direct all urls to "sites/default/files..etc" using htaccess rules?

I can't modify the content and find/replace the urls in the database so I'm looking for a solution to avoid that.

Appreciate your help.

  • The reason is the old site didn't have a second language and it is being added and prepared right now on the development server. I'm afraid playing with the DB would mess up the old and new content. So I want to maintain the old/new site links and items as much as possible to make life easier when I re-upload the site to the production server. – Ahmed Jabar Jan 8 '13 at 4:18
  • Another way to fix this problem [enter link description here][1] That decision is more correctly. [1]: drupal.stackexchange.com/questions/38043/… – Andriyun May 16 '14 at 15:40
1

If you want to use mod_rewrite, here's what to put in .htaccess:

RewriteEngine on
RewriteRule ^en/(.*)$ /$1

Btw. this has little to do with Drupal, it is either an Apache thing or a DB thing (depending on how you decide to solve it).

  • I had to add another / in front of the $1 to prevent my whole path user/example/domains/example.com/private_html from being appended to the url. So I used RewriteRule ^en/(.*)$ /$1. – Neograph734 Apr 10 '16 at 10:38
  • Updated answer. – Free Radical Apr 10 '16 at 11:36
  • For some reason this didn't work for me. The working solution is: RewriteRule ^en/(.*)$ /$1 [L,R=301] – MilanG May 30 '17 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.