加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

php – 在codeigniter中设置基本URL

发布时间:2020-12-14 23:12:11 所属栏目:资源 来源:网络整理
导读:我在代码点火器中有这样的目录结构: Appsite -website -application -images 当我在index.php中访问图像时,我使用了: ? 主页 我认为在代码点火器中访问图像或库时包含http:// localhost不是一个好习惯.所以我试着改变config.php中的$config [base_url] to

我在代码点火器中有这样的目录结构:

 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;Homeu0026lt;/au0026gt;u0026lt;/liu0026gt;

但我得到错误.它说没找到物体.有人可以帮帮我吗?

最佳答案
在Config.php中

$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帮助程序

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读