在CodeIgniter 4中,带有' www的URL。未在基本URL()中显示
在用www的CodeIgniter 4 URL中。未在基本URL()中显示www。
$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://". $_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
此源代码也无法正常工作。
我该如何解决?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
base_url([$ uri ='' >
在项目根部以
.env
文件定义基本URL。例子:base_url([$uri = ''[, $protocol = null]])
Define your base URL in your
.env
file at the root of your project. Example:首次设置一个CodeIgniter项目时,您会在根中看到
env
文件,复制该文件并将其重命名为.env
带有点。然后在该文件夹中查看行
23
我认为或只是寻找#app.baseurl ='http:// localhost:8080/'
然后删除哈希(www。
>#),只需 要将您的
$ baseurl
在app \ config \ app.php
中更改为域。fyi:
什么是.env文件?
.ENV文件或Dotenv文件是一个简单的文本配置文件,用于控制您的应用程序环境常数。
我建议您查看Codeignter官方文档Asell aswell aswell
when you first setup a codeigniter project you will see a
env
file in your root, copy that file and rename it to.env
env with a dot.Then in that folder look at line
23
I think or just look for#app.baseURL = 'http://localhost:8080/'
Then Remove the hash(#
) and just addwww.
in front of localhost like thisapp.baseURL = 'http://www.yourdomain.com/'
Also Remember to change your
$baseURL
inapp\Config\App.php
to your domain.FYI:
What is a .env file?
A .env file or dotenv file is a simple text configuration file for controlling your Applications environment constants.
I recommend you look at the codeignter official docs aswell