In Drupal 8 mod_rewrite is no longer required. However I am experiencing problems with generating files through Image styles when mod_rewrite is not enabled. I have not been able to spot any warnings - hook_requirements() etc. - that this should be a problem.
When trying to access an url such as http://host/sites/default/files/styles/thumbnail/public/filename.jpg?ito... on a server without mod_rewrite results in a 404 with the following line written to the server log: File does not exist: /path/to/webroot/sites/default/files/styles/thumbnail/public/filename.jpg. As far as I can tell Apache does not go through PHP here.
Enabling mod_rewrite fixes the issue.
Environment info:
- Apache 2.4.10
- PHP 5.5.47-0+deb8u1
- Drupal 8.1.1
Comments
Comment #2
kasperg commentedTo be honest I do not know whether mod_rewrite is required or not.
https://www.drupal.org/requirements/webserver says yes but #2382513: Regression fix: allow Drupal 8 to work without Apache mod_rewrite indicates no.
Comment #3
tetranz commentedI was caught out by this.
I just setup a new development system (Ubuntu 16.04 LTS). Everything worked wonderfully except image styles. I finally found this issue realized that I had forgotten to enable mod_rewrite.
I haven't looked to see if it is fixable or not. If not, then I think there should be a documented warning somewhere.
Comment #4
tetranz commentedI took a look at this.
Image styles do not work without mod_rewrite because of the security related SetHandler lines in sites/default/files/.htaccess
i.e.,
With those in place, the FallbackResource directive in the root .htaccess does not work. A request to a non-existent /sites/default/files/someimage.png does not fall back to index.php. It returns a 404.
Images styles work without mod_rewrite if the SetHandler lines are removed or commented out.
I don't know if there is a secure solution to this. We probably need comments from some security experts.
Even though it's been long closed, I'll add https://www.drupal.org/node/2382513 as a related issue. The final result of that issue perhaps isn't as complete as was thought at the time.
Comment #5
tetranz commentedComment #6
kattekrab commentedComment #7
kattekrab commentedYet another sting related to the behaviour change around Clean URLs for D8.
Documentation here: https://www.drupal.org/getting-started/clean-urls#enabling-8
Comment #10
marysmech commentedI had experiencing same problem with images styles. Image crops were not generated and there was no error.
After little debugging I have found out that if I remove "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003" from "files" .htaccess everything work. Than I have found this thread and enabled apache's mod_rewrite and images style are now generated correctly.
Thank you!
Comment #11
zorlin commentedChiming in to say that we were having issues with image generation etc due to the .htaccess file in sites/default/files - and had removed it as a temporary workaround on 2 different Drupal8 sites.
I was unhappy at the idea of degrading our security and so have been researching a proper fix - simply enabling mod_rewrite has fixed the issue and allowed us to put the .htaccess back into proper usage.
Thanks to @chi on Slack for pointing me to this page. Very glad to have this issue solved.
(So, yes, it probably /does/ require mod_rewrite still ;))
Comment #15
renrhafI encountered the same issue with Drupal 8.6.1 and using Apache without mod_rewrite enabled.
Everything seemed to work properly but the image styles.
Comment #18
kristen polThis was a problem recently for simplytest.me. Adding mod_rewrite fixed the issue:
#3162126: Image styles either aren't generated or can't be downloaded
This is a big deal and it's not obvious what's wrong because there are no errors in the Drupal logs.
Comment #22
larowlanThe webserver requirements now say the following
So we can mark this as fixed