magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Can't have some media and static url different from base url (CDN like) #11233

Closed nelero closed 7 years ago

nelero commented 7 years ago

Hi, if we want to serve media and skin files from different URLS as base url, all resources return 404.

Preconditions

Magento CE 2.1.9 PHP 7.0.3 only 1 Website / 1 store / 1 storeview

Steps to reproduce

  1. configure unsecure base_url with http://www.domain.com/ and secure_base_url with the same : http://www.domain.com/
  2. configure unsecure and secure static url and media url with http://www.cdndomain.com/
  3. The cdndomain.com (with and without www.) is pointing to the same magento root folder as domain.com
  4. Validate

Expected result

  1. resources (JS, CSS and media) should be loaded from www.cdndomain.com and displayed well

Actual result

All resources are called with http://www.cdndomain.com/ => good But all resources send a 404 header and the content (HTML) of 404 page not found instead of the right content.

ihor-sviziev commented 7 years ago

@nelero but for static URL you need to use following url: http://www.cdndomain.com/static/, and for media - http://www.cdndomain.com/media/. Than you will not have 404 pages.

nelero commented 7 years ago

@ihor-sviziev Yes you're right. But if i change them, still 404 errors. (in Admin and in front office). For example : http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/extjs/resources/css/ext-all.css (css loaded in admin pages) still 404 errors.

Start for my admin page :

<!doctype html>
<html lang="fr-FR">
    <head >
        <script>
    var BASE_URL = 'http://www.domain.com/manager/admin/index/index/key/a154b489662ee840a35551658331ee1c16415bb9bd8ef28c648f62510ea8b37e/';
    var FORM_KEY = '1XI1zJBUiLriRFnC';
    var require = {
        "baseUrl": "http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR"
    };
</script>
        <meta charset="utf-8"/>
<meta name="robots" content="NOINDEX,NOFOLLOW"/>
<meta name="viewport" content="width=1024"/>
<title>Configuration / Settings / Stores / Demo store Magento Admin</title>
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/extjs/resources/css/ext-all.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/extjs/resources/css/ytheme-magento.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/HelloBrave_Core/css/admin.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Lof_All/css/styles.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Lof_Formbuilder/css/styles.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Tigren_Core/css/core.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/jquery/jstree/themes/default/style.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/css/styles-old.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/css/styles.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Blackbird_Monetico/css/styles.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Magento_Paypal/styles.css" />
<link  rel="stylesheet" type="text/css"  media="all" href="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/jquery/colorpicker/css/colorpicker.css" />
<script  type="text/javascript"  src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Bss_FastOrder/js/jscolor.min.js"></script>
<script  type="text/javascript"  src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/requirejs/require.js"></script>
<script  type="text/javascript"  src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/mage/requirejs/mixins.js"></script>
<script  type="text/javascript"  src="http://www.cdndomain.com/static/_requirejs/adminhtml/Magento/backend/fr_FR/requirejs-config.js"></script>
<script  type="text/javascript"  src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Bss_Amp/js/jscolor.min.js"></script>
<script  type="text/javascript"  src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/Mageplaza_Core/js/jscolor.min.js"></script>
<link  rel="icon" type="image/x-icon" href="http://www.cdndomain.com/media/favicon/stores/1/favicon.png" />
<link  rel="shortcut icon" type="image/x-icon" href="http://www.cdndomain.com/media/favicon/stores/1/favicon.png" />
            </head>
    <body data-container="body" data-mage-init='{"loaderAjax": {}, "loader": { "icon": "http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/images/loader-2.gif"}}' id="html-body" class="adminhtml-system-config-edit page-layout-admin-2columns-left">
        <div class="menu-wrapper">                        <a
            href="http://pprod2.roger-junca.com/manager/admin/"
            data-edition="Community Edition"            class="logo">
            <img class="logo-img" src="http://www.cdndomain.com/static/adminhtml/Magento/backend/fr_FR/images/magento-icon.svg"
            alt="Panneau d’administration de Magento"/>
        </a>

i've also made :

but still no change

ihor-sviziev commented 7 years ago

@nelero usually CDN providers just forward all requests in case they don't have any cache, so might be your CDN isn't configured correctly. Is this file exists if you will change domain to www.domain.com?

nelero commented 7 years ago

@ihor-sviziev : thanks for your reply. In fact it's not a cdn provider : cdndomain.com is a domain i own and manage and i pointed it like www.domain.com on the magento root folder. if i go to www.cdndomain.com, i see the magento website, like www.domain.com

If i put http://www.domain.com/static/ and http://www.domain.com/media/ => KO the files returned 404. But you got me on the right way ! If i reverse to empty url (to get the default secure and unsecure base url), files are ok and the right url are

pub/static and pub/media !

so with http://www.cdndomain.com/pub/static/ and http://www.cdndomain.com/pub/media/ everything is fine !

thanks a lot !

orlangur commented 7 years ago

so with http://www.cdndomain.com/pub/static/ and http://www.cdndomain.com/pub/media/ everything is fine !

Seems like a misconfiguration to me: you should never have /pub/ in URLs. Web server configuration should point to pub folder in Magento root, not to Magento root itself.

Closing as it looks like nothing to fix from Magento side. @nelero @ihor-sviziev thanks for collaboration and helping each other.