Hi,

Peharps i missed something but here's my problem:

- i have a local site - my development site - installed in htdocs/drupal/xxx/ folder.
- i have a test site installed in www.xxx.com/DRUPAL
- i have a production site that will be installed in www.xxx.com

When i set my image url in CKeditor i need to specify this url - as i didn't change the default drupal upload file folder:

- local site: drupal/xxx/sites/default/files/imagename.jpg
- test site: DRUPAL/sites/default/files/imagename.jpg
- prod site: /sites/default/files/imagename.jpg

So as the required path is from site base url, all my image paths are not portable between my site.

Is there a way to make image url portable between my site properly?

Thanks in advance

Comments

nugen’s picture

Assigned: nugen » Unassigned
nugen’s picture

Hi all,

I find out a way to my problem. So i just want to expose it in case it may helps others...
In the meantime i have added ckfinder for browsing my images.

So the idea is to use a virtual name in your images path and then use RewriteRule in .htaccess to set the right path, so when
you change your server from local to production you just have to update the .htaccess without updating your DB :

1) Configure default path images in ckfinder :
- Go to Administer>Site configuration>CKeditor
- Edit your ckeditor profile (in my conf it is advanced in which i enabled ckfinder) and go to file explorer parameters
- Set the path for uploaded path like this : virtualname/%f/ - where 'virtualname' will be the virtual part of your url and %f - Drupal file system path where the files are stored (sites/default/files).

Now when you will add with ckfinder an image, it will use virtualname/sites/default/files/yourImage.jpg as path copied in the src attribut.

2) Edit your .htaccess located in your root drupal directory and add:

- If your drupal is installed directly in your root site, use:

RewriteRule ^(.*)virtualname(.*)$ http://www.YourSite.com/$2 [L,QSA,NC]

- If your drupal is installed in a sub-directory use:
RewriteRule ^(.*)virtualname(.*)$ http://www.YourSite.com/SUB-DIRECTORY-NAME/$2 [L,QSA,NC]

So when you change directory installation you just have to update http://www.YourSite.com/SUB-DIRECTORY-NAME/ in order to rewrite correctly your images path.

jcisio’s picture

Status: Active » Fixed

Then marking it as fixed.

But I don't understand why you can upload once and use it in 3 places. Are you using symbolic link or bind mount?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.