Of course. Let's break down what cfg_basehost is in DedeCMS, why it's important, and how to configure it correctly.

What is cfg_basehost?
In simple terms, cfg_basehost is a global configuration variable in DedeCMS that stores your website's base URL.
It's defined in the configuration file include/common.inc.php. When you install DedeCMS, it sets this variable to the domain you provided during the installation process.
Example:
If your website is https://www.example.com, the cfg_basehost variable will be set to:
'https://www.example.com'
Why is cfg_basehost So Important?
This variable is the cornerstone of how DedeCMS generates absolute URLs for your website. Instead of hard-coding URLs throughout the system, DedeCMS uses this central variable. This provides several key benefits:

-
Portability: If you ever need to move your website from a development server (e.g.,
http://localhost/my_site) to a live server (e.g.,https://www.example.com), you only need to change this single value in the configuration file. You don't have to hunt through hundreds of files to update URLs. -
Consistency: It ensures that every link generated by the system (links to articles, images, CSS, JavaScript, etc.) uses the correct base domain. This prevents broken links and mixed content issues (e.g.,
httpon anhttpspage). -
Functionality: Many core DedeCMS functions rely on
cfg_basehostto build their output. For example:{dede:global.cfg_basehost/}: This is a standard DedeCMS template tag you can use directly in your HTML templates to output the base URL.- Image Paths: When DedeCMS generates the path for an image uploaded to the media library, it prepends
cfg_basehostto make it a full, accessible URL. - URL Rewriting: It works in conjunction with the URL rewriting rules to ensure that all links, including those in the
<head>section (for canonical tags, Open Graph tags, etc.), are correct.
Where is cfg_basehost Defined and Used?
Definition (Where to set it)
The variable is defined in the file:
/include/common.inc.php

You will find a line that looks like this:
$cfg_basehost = 'https://www.your-domain.com'; // <--- YOU WILL EDIT THIS LINE
How to Edit It:
- Access your website's files via FTP or a File Manager in your hosting control panel.
- Navigate to the
/include/directory. - Edit the file
common.inc.php. - Find the
$cfg_basehostline and change the URL to your correct domain. - Crucially, save the file and upload it back to your server.
Important Note: If your website uses HTTPS (SSL certificate), you must use
https://in thecfg_basehostvalue. Usinghttp://on an HTTPS site will cause browser security warnings (mixed content) and break functionality.
Usage (Where it's used)
-
In DedeCMS Templates: You can use the template tag directly in your
.htmtemplate files.<!-- Link to your homepage --> <a href="{dede:global.cfg_basehost/}/">Go to Homepage</a> <!-- Use in Open Graph tags for social media sharing --> <meta property="og:url" content="{dede:global.cfg_basehost/}{dede:field name='arcurl'/}" /> -
In PHP Code: It's used extensively within the DedeCMS PHP codebase to generate full URLs. For example, in the
arc.archives.class.phpfile (which handles article displays), it's used to build the canonical URL for SEO.
Troubleshooting Common Problems with cfg_basehost
If cfg_basehost is not set correctly, you will likely experience one or more of the following issues:
Problem 1: Images Not Showing
Symptom: Images in your articles or on your site appear as broken links (a generic image icon).
Cause: The cfg_basehost is either incorrect (e.g., pointing to localhost instead of your live domain) or missing the https:// prefix.
Solution:
- Check if your site is running on
httporhttps. - Edit
/include/common.inc.phpand ensure$cfg_basehostpoints to the fully qualified domain name with the correct protocol.
Problem 2: Mixed Content Security Warnings in Browser
Symptom: Your browser's address bar shows a "Not Secure" warning, or the console logs errors about "mixed active content."
Cause: Your site is loaded over https, but cfg_basehost is set to http://www.example.com. This causes the browser to block insecure resources (images, scripts) from being loaded.
Solution:
- Edit
/include/common.inc.php. - Change
$cfg_basehostfromhttp://...tohttps://....
Problem 3: Links are Incorrect After Moving a Site
Symptom: You moved your DedeCMS site from one domain to another, but all the links still point to the old domain. Cause: You updated the database (for posts, etc.) but forgot to update the core configuration variable. Solution:
- Edit
/include/common.inc.php. - Change the value of
$cfg_basehostto your new domain name. - Save the file. Clear your browser cache and the server's cache (if you have a caching plugin like PHP Opcode Cache enabled).
Summary
| Feature | Description |
|---|---|
| What it is | A global variable in DedeCMS that stores your website's base URL (e.g., https://www.example.com). |
| Where to set it | In the file /include/common.inc.php. |
| Why it matters | It ensures all URLs generated by the system are correct, portable, and consistent. |
| Common Fix | If images are broken or you get security warnings, the most likely cause is an incorrect protocol (http vs https) or an outdated domain name in this variable. |
