System File Path instead of URLs in Magento



Recently I found a problem with CSS and JavaScript paths in Magento when I was moving the code from one hosting to another hosting. When I completely moved the code and database I visited the admin url and front url I found CSS and JavaScript was not loading. When I checked the HTML source I found that Magento using system file path instead of urls and the HTML source code looked like this:

<link rel="stylesheet" type="text/css" href="home/user/public_html/skin/frontend/default/default/css/styles.css" media="all" />
<link rel="stylesheet" type="text/css" href="home/user/public_html/skin/frontend/base/default/css/widgets.css" media="all" />
<link rel="stylesheet" type="text/css" href="home/user/public_html/skin/frontend/default/default/css/print.css" media="print" />
<script type="text/javascript" src="home/user/public_html/js/prototype/prototype.js"></script>
<script type="text/javascript" src="home/user/public_html/js/lib/ccard.js"></script>
<script type="text/javascript" src="home/user/public_html/js/prototype/validation.js"></script>
<script type="text/javascript" src="home/user/public_html/js/scriptaculous/builder.js"></script>
<script type="text/javascript" src="home/user/public_html/js/scriptaculous/effects.js"></script>
<script type="text/javascript" src="home/user/public_html/js/scriptaculous/dragdrop.js"></script>
<script type="text/javascript" src="home/user/public_html/js/scriptaculous/controls.js"></script>
<script type="text/javascript" src="home/user/public_html/js/scriptaculous/slider.js"></script>
<script type="text/javascript" src="home/user/public_html/js/varien/js.js"></script>
<script type="text/javascript" src="home/user/public_html/js/varien/form.js"></script>
<script type="text/javascript" src="home/user/public_html/js/varien/menu.js"></script>
<script type="text/javascript" src="home/user/public_html/js/mage/translate.js"></script>
<script type="text/javascript" src="home/user/public_html/js/mage/cookies.js"></script>

Then I have checked Secure/Unsecure base URL in ‘core_config_data’ table by mysql client and URLs were OK. Then I thought it might be because of caching problem so I deleted all the caches no good and then I tried with server settings but there is no success.

Finally I found the problem that it was merging CSS and JavaScripts and folder permission issue. But the HTML source showing independent CSS and JavaScript so that was hard to guess the actual problem.

Then I checked ‘core_config_data’ table with following query:

 SELECT *
FROM `core_config_data`
WHERE `path` LIKE '%merge%'
System File Path instead of URLs
CSS and JS files merging is ON

Then I found that CSS and JavaScript merging was on. I turned off the merging of CSS and JavaScript by putting ‘dev/js/merge_files’ and ‘dev/css/merge_css_files’ value to 0. Then I reloaded the pages again and now CSS and JavaScript was working fine. But the question is why it was not working when the merging was ON?

Magento generates the assets files in media folder this media directory should be writable by the apache user. Magento creates merged JS and CSS files in media directory so it is clear it was permission issue. Now I changed the permission of media folder to 777 from 755 and turned On the merging and reloaded the pages, all worked fine. Now HTML source showing merged path for CSS and JS.

So with this investigation I found that “Magento using System File Path instead of URLs” because of incorrect permission of media directory. Hope this post will help you.