This issue:
#580058: allow files to be referenced only with /files/ (instead of /sites/fqdn/files)
says that it's possible to use URL rewriting so that sitename is no longer in the url, e. g. "example.com/files/attachment.wtf" instead of "example.com/sites/exmaple.com/files/attachment.wtf".
This would immediately resolve the development→production migration pain for me.
But i found no documentation on how to enable and use this feature.
So... How do i do that? Which files to modify, etc?
Also, will it work okay for domain aliases? This is very important.
Thank you!
Comments
Comment #1
lolmaus commentedComment #2
lolmaus commentedOkay, i found this chapter of Aegir documentation: Injecting into site vhosts.
I've created a file
/var/aegir/.drush/filesrewrite.drush.incwith the following content:It works, the files are now accessible via "example.com/files/file.wtf".
The question is: is there a way to make Drupal serve files with such URLs?
One may attach a file to a post and paste the URL to the file into the post's body. When i stage the site, this URL will break. So i wonder whether Drupal can provide short URLs in the first place?
Comment #3
omega8cc commentedIt is already built-in feature/rewrite: http://drupalcode.org/project/provision.git/blob/refs/heads/6.x-1.x:/htt...
You don't need to add anything extra to use short URL.
However, using short URLs in Drupal natively/automatically is not possible. You can use them when you enter/use the URL manually.
Comment #4
omega8cc commentedAlso, Aegir rewrites URLs also in the content, and at least in the BOA fork also for Drupal 7 sites: http://drupalcode.org/sandbox/omega8cc/1074910.git/blob/HEAD:/platform/d...
Comment #5
lolmaus commentedI've got Aegir installed from Debian packages. I've just tried renaming a site, and its content pointing to an actual attachment (e. g.
<img src="http://old.example.com/sites/old.example.com/files/ming-face.png" alt="test"/>) has not been fixed. :(Is there a way i can enable content rewriting as you mention above?
Before Aegir, i used to use symlinks to resolve the issue. It was very simple. But on Aegir, using symlinks in place of the
sites/example.com/filesbreaks migrations.I find it a major flaw of D7. Drupal.org itself has this problem hacked somehow, but all other Drupal-powered sites have to face this issue. :( Before asking, i've googled extensively and i found a lot of people struggling with the issue. I just don't understand how staging sites can be possible with this issue existing.
So... is your suggestion available for vanilla Aegir from Debian packages?
Comment #6
lolmaus commentedOMGF! This problem is five years old already!!
#275022: When moving or aliasing sites, permanently redirect sites/somesite.com/files to sites/$site_url/files.
Comment #7
omega8cc commentedYou just need to replace your
/var/aegir/.drush/provision/platform/drupal/deploy_7.incfile with BOA version.It was already submitted for review here, but core devs decided to refuse to accept the request, so it is included only in BOA.
Comment #8
lolmaus commentedThank you, omega8cc, i'll give it a try. You're very kind and helpful.
Comment #9
busla commented@omega8cc: Do I understand you correctly that BOA uses the rewrite by default?
My image urls are: "mysite.com/sites/mysite.com/files/images/myimage.jpg"
Comment #10
busla commentedI hope it´s ok if I re-open this issue. Please correct my if I´m wrong.
Comment #11
busla commentedchanging version
Comment #12
omega8cc commentedAegir (and BOA) does the rewrite for /files/* but it doesn't modify native URLs generated by Drupal which have to use multisite specific paths. The rewrite is useful only to reference files in e-mails, in the content etc. if you want the short URL, of course.
Comment #13
busla commentedOk, so for images on my server, that are controlled by file_entity, I would need to use a path alias to change this?
Comment #14
omega8cc commentedNo. Any aliasing inside Drupal works only for dynamically generated pages, not for files. Also, I don't think you can change that anyway. It is hardcoded on the settings.php level to satisfy Drupal core behaviour. I mean, you shouldn't mess with Drupal core to modify the paths it expects by default.