我在代码点火器中有这样的目录结构:
Appsite
-website
-application
-images
当我在index.php中访问图像时,我使用了:
< img src =“http://localhost/Appsite/website/images/images.PNG”
并且href是:
< li class =“”>< a href =“http://localhos/tAppsite/website/index.php/home/”>主页< / a>< / li>
我认为在代码点火器中访问图像或库时包含http:// localhost不是一个好习惯.所以我试着改变config.php中的$config [‘base_url’]
to $config [‘base_url’] =“http://”.$_ SERVER [“HTTP_HOST”].“/”;
现在我更新了我的图像源和其他库源我删除了localhost和我的目录文件夹的名称:
< img src =“images / images.PNG”>
< li class =“”>< a href =<?php echo base_url;?> /website/index.php/home/\”\u0026gt;Home\u0026lt;/a\u0026gt;\u0026lt;/li\u0026gt;
但我得到错误.它说没找到物体.有人可以帮帮我吗?
$config['base_url'] = 'http://localhost/Appsite/website/';
$config['index_page'] = '';
# If online site
# $config['base_url'] = 'https://stackoverflow.com/';
在.htaccess(外部应用程序文件夹) – 删除URL中的index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$index.php?/$1 [L,QSA]
访问URL
访问图像
从autoload.php使用base_url加载URL帮助程序
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。