Failed to load resource: the server responded with a status of 403 (Forbidden)

10.1k views Asked by At

I am getting this error while deploy php project in wamp server.Actually i used codeigniter php framework.

request URL is http://localhost:80/index.php

below is the code.

<?
if(isset($js)){
  if(is_array($js)){
    if(count($js) >= 1){
        foreach($js as $file){
            if(file_exists("../www/js/{$file}")){
    ?>      
    <script type="text/javascript" language="javascript" src="<?php echo  
    base_url();?>js/<?=$file?>"></script>
    <?
            }
        }
    }
  } else {
    ?>      
    <script type="text/javascript" language="javascript" src="<?php echo 
    base_url();?>js/<?=$js?>"></script>
    <?
  }
}
?>

This is showing error on browser like

GET http://localhost/js/%3C?=$file?%3E 
GET http://localhost/js/%3C?=$js?%3E 

Why is this error occurring.Please help me.

1

There are 1 answers

1
RiggsFolly On

This is probably because you are using PHP short_open_tags

i.e.

<?=$file?>

But in its default out of the box state PHP has the parameter turned off.

Edit php.ini to make sure you edit the correct php.ini file there are normally 2

Use the wampmanager menus -

wampmanager -> PHP -> php.ini

Search for

short_open_tags = Off

and change it to

short_open_tag = On

However the better solution would be to not use short tags, therefore your code will be universally transportable. So you could instead change the code to be

<?php echo $file;?>

It's a bit longer, but will work on any PHP configuration.