Magento Path to CSS and JS incorrect

2019-07-11 19:07发布

This website has broken after cache clearing: http://isaacgrainger.co.uk/

I've done the following as per other suggestions on here:

  1. checked folder permissions
  2. ran SQL script to turn merge CSS and JS off
  3. checked all permissions media and var folders
  4. checked base URLs- all fine

I am totally stumped. in the backend (unstyled) there seems to be no way to change CSS preferences. I didn't build this project so I don't know how the original developer configured the back end of Magento.

标签: magento url
6条回答
地球回转人心会变
2楼-- · 2019-07-11 19:20

It's not a file system permissions issue or an incorrect secure/unsecure base URL. It's probably an incorrect Base Skin URL. Here's an example of your stylesheet link:

<link rel="stylesheet" type="text/css" href="/home/sites/isaacgrainger.co.uk/public_html/skin/frontend/base/default/css/normalize.css" media="all" />

The problem is the href attribute. /home/sites/isaacgrainger.co.uk/public_html/ looks more like a path in your file system than a web address.

There are a lot of ways this could have happened, but the most likely and least painless would be if your base_skin_url was incorrect.

If it is, you can fix it with this SQL query:

UPDATE core_config_data SET value='{{secure_base_url}}skin/' WHERE path='web/secure/base_skin_url';
UPDATE core_config_data SET value='{{unsecure_base_url}}skin/' WHERE path='web/unsecure/base_skin_url';

Or if you have admin access in the backend, you can change it there too:

System > Configuration > General > Web > {{Unsecure||Secure}}

Find the fields labeled "Base Skin Url" and change them to this:

{{secure_base_url}}skin/
{{unsecure_base_url}}skin/

(secure for secure, unsecure for unsecure)

查看更多
Deceive 欺骗
3楼-- · 2019-07-11 19:23

My issue ended up being switching the mode of php delivery at the server; Fast CGI via Apache instead of Apache via Apache - viola, a normal admin loading all css at the SSL.

查看更多
家丑人穷心不美
4楼-- · 2019-07-11 19:26

I have experienced same problem. Mine was not with the secure/unsecure path. It was because the permissions for the folders. I meant the ownership of the directories, when I changed the ownership to right user, all went smooth.

enter image description here

查看更多
女痞
5楼-- · 2019-07-11 19:31

Check broken path

View the source of your page and click the CSS links, if it is pointed correctly it should bring you to the CSS page.

Solution

Need to go to phpMyAdmin and do this:

SELECT * FROM `core_config_data` WHERE `path` LIKE '%merge%'

Then change values from 1 to 0 Clear cache and all will be ok

查看更多
Rolldiameter
6楼-- · 2019-07-11 19:35

The problem is from your stylesheet reference call

This displays a valid js call from

isaacgrainger.co.uk/media/js/8663a1971e27f568fd8bd9defe9d8201.js

But when I tried

isaacgrainger.co.uk/home/sites/isaacgrainger.co.uk/public_html/skin/frontend/base/default/css/normalize.css

it returns 404. So my suggestion is to try this, its from my own local Magento setup

System > Configuration > General > Web > {{Unsecure||Secure}}

This is for Unsecure Tab

Base URL
    http://isaacgrainger.co.uk/ 
Base Link URL
    {{unsecure_base_url}}   
Base Skin URL
    {{unsecure_base_url}}skin/  
Base Media URL
    {{unsecure_base_url}}media/ 
Base JavaScript URL
    {{unsecure_base_url}}js/
查看更多
干净又极端
7楼-- · 2019-07-11 19:35

The solution for me was to do with the base urls for secure and unsecure being incorrect for my install location as I was running magento without an actual domain name on port 80 (basically running it locally using host file changes in place of the usual DNS for a live domain).

My first step was to go into phpmyadmin and locate my magento database. Then find the core_config_data table and change the following fields:

web/unsecure/base_url
web/secure/base_url

Ensure that these urls match with the url for your magento install.

It was not possible for me to change these via the backend of Magento due to the jscript files having incorrect paths and therefore not loading to make the save button work in the backend.

Once you have changed these two fields you must be sure to clear the cache for Magento in order for your changes to take effect.

You can do this in two ways.

First Method:

Through the Magento Admin Panel (this may not work as in my case the buttons did not work on my back end due to the url issue for the js files)

  1. Log in to your Admin Panel account
  2. Go to the System -> Cache Management section
  3. Click on the Flush Magento Cache button

Second Method:

  1. Open an SSH connection to your server
  2. cd to your magento install directory
  3. run the following command to clear the cache

    sudo rm -rf var/cache/*

  4. Reload your page and the css and jscript should all be working

查看更多
登录 后发表回答