php– 在codeigniter中设置基本URL

php– 在codeigniter中设置基本URL,第1张

概述我在代码点火器中有这样的目录结构: Appsite -website -application -images 当我在index.php中访问图像时,我使用了:< img src =“http://localhost/Appsite/website/images/images.PNG”并且href是: < li clas

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

 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.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 onRewriteCond  !^(index\.PHP|assets|image|resources|robots\.txt)RewriteCond %{REQUEST_filename} !-fRewriteCond %{REQUEST_filename} !-dRewriteRule ^(.*)$index.PHP?/ [L,QSA]

访问URL

href="

访问图像

访问CSS

从autoload.PHP使用base_url加载URL帮助程序 总结

以上是内存溢出为你收集整理的php – 在codeigniter中设置基本URL全部内容,希望文章能够帮你解决php – 在codeigniter中设置基本URL所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1125269.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)