在CodeIgniter 4中,带有' www的URL。未在基本URL()中显示

发布于 2025-02-10 22:41:01 字数 409 浏览 3 评论 0 原文

在用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']);

此源代码也无法正常工作。

我该如何解决?

In Codeigniter 4 URL with www. not shown www in base URL().

$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']);

This source code is also not working.

How can I solve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

习ぎ惯性依靠 2025-02-17 22:41:04

base_url([$ uri ='' >

按照您的配置文件中指定的返回您的站点基础URL。示例:

 <?php

echo base_url();
 

在项目根部以 .env 文件定义基本URL。例子:

app.baseURL = 'http://www.your-domain.com'

base_url([$uri = ''[, $protocol = null]])

Returns your site base URL, as specified in your config file. Example:

<?php

echo base_url();

Define your base URL in your .env file at the root of your project. Example:

app.baseURL = 'http://www.your-domain.com'
奢欲 2025-02-17 22:41:04

首次设置一个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 add www. in front of localhost like this app.baseURL = 'http://www.yourdomain.com/'

Also Remember to change your $baseURL in app\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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文