简体   繁体   English

Wamp 403上的codeigniter禁止错误

[英]codeigniter on wamp 403 forbidden error

I set up a codeigniter project on my wamp www folder 我在wamp www文件夹上设置了一个codeigniter项目

The assets of my project is in 'assets' folder which is in the same folder as the application folder. 我项目的资产位于“资产”文件夹中,该文件夹与应用程序文件夹位于同一文件夹中。

However when I access my localhost, the css,images and js which are in the asset folder is unable to load. 但是,当我访问本地主机时,资产文件夹中的css,images和js无法加载。

When I type localhost/assets instead, I can access them. 当我键入localhost / assets时,我可以访问它们。

I set http.conf in the apache folder to set to "Allow from all" as well. 我也将apache文件夹中的http.conf设置为“全部允许”。

when i access the url from the developer tools for chrome, I have characters within the url like this 当我从开发人员工具访问chrome的网址时,网址中包含这样的字符

%3C?=%20base_url()%20?%3Eassets/img/a.jpg %3C?=%20base_url()%20?%3Eassets / IMG / A.JPG

Any idea what is wrong here? 知道这里有什么问题吗?

It seams that the function base_url() is not executed and just printed in your view. 它表明函数base_url()未执行,只是在您的视图中打印。

Try to enclose the function in a php block and echo it out with the path to the asset. 尝试函数封装在php块中,并用资产的路径将其回显。

<?php 
  echo base_url() . 'assets/img/a.jpg';
?>

Or as stealthyninja mentioned in the comment, the short-open-tag you used is interpreted as text. 或如评论中提到的steathyninja一样,您使用的short-open标签被解释为文本。 You can enable it in the php.ini with 您可以使用以下命令在php.ini启用它

short_open_tag=On

When you can't modify the php.ini , you can enable it in the codeigniter config.php with 当您无法修改php.ini ,可以在codeigniter config.php使用以下命令启用它:

$config['rewrite_short_tags'] = TRUE;

Now the short open tags are interpreted right 现在, 简短的开放标签被正确解释

<?= base_url() . 'assets/img/a.jpg' ?>

check you config.php file: 检查您的config.php文件:

$config['rewrite_short_tags'] = TRUE;

or try this : 或者试试这个:

<?php echo base_url()?>assets/img/a.jpg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM