Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2017 17:17
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
[Magento2] Make sure image are served from /pub/media AND /media
# If your Apache already serve request from the /pub dir
# This will allow malformed URL to reach their destination.
# Alias /pub the pub/ dir on disk
# Replace path with your actual path
Alias "/pub" "/var/www/public/pub"
location /pub/ {
alias /var/www/public/pub;

If you use Magento from the root dir you might want to make sure all your images url are valid. There are some known issue with this but it's generally considered a good practice.

Maybe you have image path like instead of

The best way to fix this is to tell your server to ignore the /pub in the URLs. Do not set redirection!

Find above the lines to add to your server configuration.

Copy link

Hi, you're missing a trailing slash on that nginx config;

location /pub/ {
alias /var/www/public/pub/;


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment