• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error 404 Page Not Found --> js

Hi all,
I have configured today MAMP on my laptop in order to have my site accesible even locally. I have modified my .htacces file, created my db unders MAMP and everything seems to work properly except for some js files.
Checking my site I have tried to login (login calls a js) and it's not working. Having a look into my log file I noticed the row below

404 Page Not Found --> js

Seems like that my js file is not called or the link is not recognized.
Checking on internet I have found another post with the same same so I have checked my base_url() that seems to be ok. Moreover, if I recall my js file with the same link is inside the page that calls the same js, I'm able to access on it and see its contents. I guess there are no issues with the link.
Is there something more that I can check?

Thanks in advance

You may want to check whether you are using relative urls to your js files. This is the most common thing to go wrong when using 'pretty' urls like CI does.

A good solution is to use absolute URLs using the url helper

Another solution is to set a base href tag in your page <head>.

// html head section
    <base href="<?php echo base_url();?>" />

// Replace $ with s in script tags!

    <$cript type="text/javascript" charset="utf-8">
            var base_url = "&lt;?php echo base_url(); ?&gt;";
            var site_url = "&lt;?php echo site_url(); ?&gt;";
        // ]]>

Thank you for your answers first of all.
I think I'm not getting the point so I try to explain better what I have done.

My MAMP webroot is like


and inside my config file I have the configuration below

$config['base_url']           = $PROTOCOL.$_SERVER['HTTP_HOST']."/";
$config['front_base_url']   = $config['base_url'];
$config['file_upload_base_url']          = $config['front_base_url']."upload/";
$config['css_images_js_base_url'] = $config['base_url']."public/";

if($_SERVER['HTTP_HOST'] == "localhost:8888" )
$config['base_url']    .= "my_site_folder/";  
$config['front_base_url']   = "http://".$_SERVER['HTTP_HOST']."my_site_folder/";
$config['server_absolute_path']  = "/my_site_folder/site";
$config['file_upload_absolute_path'] = "/my_site_folder/upload/";
$config['file_upload_base_url']   = $config['front_base_url']."upload/";
$config['css_images_js_base_url'] = $config['base_url']."site/public/";
        my live server configuration is here

then within my view i have, within the head this line to recall my js file

<$cript type="text/javascript" src="&lt;?php echo css_images_js_base_url();?&gt;javascript/my_js.js"></$cript>

the source of the page is correct and like below

Quote:<$cript type="text/javascript" src="http://localhost:8888/my_site_folder/site/public/javascript/my_js.js"><$cript>

For the css and images the same approach is working.
Then I have tried to add the base_url() tag within the &lt;header&gt; and change the path of my js with a relative one but without the echo part. Same result, it's not working.
What is wrong with my configuration?

Thanks in advance for your support

This may be a file permission issue.
One you could try is to install firebug(fully functional on firefox) then monitor the Net tab to see what status per file is being returned. You can also identify what could have caused the error and what contents does the js file return.

I have installed firebug and it really helped me, I have found the issue in less than one minute. There was nothing wrong in my configuration. My mistake was a variable set with my real domain instead than my localhost. It's clear I have a lot to learn about web development and issues linked with this.


Good to know. Glad you're eager to learn more.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.