0

Problem: When I try to load the image as part of the web page, I get (blocked:other) as a response to the image request in the Chrome inspector (as opposed to 200 or 404). When I paste the image location into the address bar, it loads, so I know the path is correct. Same responses from Firefox.

Example path that loads directly in browser but not in web page/css: file:///Users/my-username/path-to-app/assets/images/give-them-beer/12-top-rated-ipas_1200.jpg

Example path that doesn't load anywhere (returns 404 in inspector): http://localhost/mysite.com/assets/images/give-them-beer/12-top-rated-ipas_1200.jpg

System info:

  • I'm working on a localhost website (Mac, using MAMP + Apache).
  • I'm using the latest version of Chrome.

Web site info:

  • I am using CodeIgniter 3.x
  • My assets directory is outside the application directory
  • I am using the full filesystem path for the image.
  • I am loading images as CSS background using inline styles

What I've investigated:

  • I've tried localhost URLs and filesystem URLs
  • .htaccess CSP options, though I can't find one that fixes the problem
  • .htaccess XSS options, but again, I can't figure out how to get around it
  • The MAMP permissions suggestions the comments. New permissions are:
    • Localhost dir: drwxr-x---+ 7 ME _www 238 Sep 10 09:37 DOCUMENTDIRECTORY
    • Website dir: drwxrwx---+ 15 ME _www 510 Sep 11 09:50 MYSITEDIRECTORY
JessycaFrederick
  • 408
  • 3
  • 10
  • Please reply to your own question instead of adding a note to the original question. See: [Ask questions, get answers, no distractions](//stackoverflow.com/tour) – LW001 Sep 29 '17 at 20:45

2 Answers2

0

You could try switching the setting in MAMP "Run Apache/MySQL server as user:" to run as your local user account rather than "www", if you haven't already.

Brett Hoffman
  • 46
  • 1
  • 5
  • Thank you for a new direction to look in! I've used the instructions here, http://ifmeister.com/mamp-file-permissions-for-a-local-development-environment/, but I don't have MAMP Pro and I can't figure out how to set the default user in MAMP. Without that last bit it didn't fix the issue, but I'm still working at it... – JessycaFrederick Sep 29 '17 at 19:45
  • I subsequently followed the permissions instructions here, https://stackoverflow.com/questions/2001881/correct-owner-group-permissions-for-apache-2-site-files-folders-under-mac-os-x and restarted Apache. No dice with either file:/// or localhost approach. :( – JessycaFrederick Sep 29 '17 at 19:59
0

It turned out it to a CodeIgniter configuration issue. I needed to add the assets folder to the .htaccess rewrite rules, like this:

RewriteEngine On RewriteCond $1 !^(index\.php|assets|resources|robots\.txt) RewriteRule ^(.*)$ index.php/$1 [L,QSA]

JessycaFrederick
  • 408
  • 3
  • 10