If your WordPress site still redirects to the temporary address provided by SwissCenter, it is usually because the URLs stored in its database or configuration files still point to that temporary domain. Here is how to force it to use your main domain.
In short: in Settings > General, put your main domain in WordPress Address (URL) and Site Address (URL). If that is not enough, define WP_HOME and WP_SITEURL in wp-config.php, then fix siteurl and home in the wp_options table.
Prerequisites
- Access to the WordPress administration interface (or FTP access if the interface is inaccessible).
- Access to the Apanel console (for the file manager and phpMyAdmin).
- Knowledge of your main domain name and the current temporary URL.
Step 1: How do I check the URLs in the WordPress settings?
- Log in to the WordPress administration interface (
http://votre-domaine/wp-admin).
- Go to Settings > General.
- Check the following fields:
- WordPress Address (URL): Ensure it contains your main domain (e.g.,
https://votre-domaine.com).
- Site Address (URL): Ensure it also matches your main domain.
- If these fields display the temporary domain, replace it with your main domain.
- Click Save Changes.
Step 2: How do I force the URLs in the wp-config.php file?
If the issue persists or if you cannot access the administration interface, force the correct URLs via the wp-config.php file.
- Connect to your hosting via FTP or a file manager (for example, the file manager in your Apanel console).
- Access the root directory of your WordPress site.
- Download and open the
wp-config.php file with a text editor.
- Add the following lines just before the line
/* That's all, stop editing! Happy publishing. */:
define('WP_HOME', 'https://votre-domaine.com');
define('WP_SITEURL', 'https://votre-domaine.com');
- Save the file and upload it to the server.
Step 3: How do I update the URLs in the database?
If the issue persists, it is possible that the temporary domain URLs are still stored in the database.
- Log in to your Apanel console and open phpMyAdmin (Hosting management > Databases card > phpMyAdmin).
- Select the database used by your WordPress site.
- Locate the
wp_options table:
- Look for the
siteurl and home entries.
- Replace the temporary domain URL with your main domain.
- Example:
siteurl: https://votre-domaine.com
home: https://votre-domaine.com
- Search for other occurrences of the temporary domain:
- Use the SQL tab to run a query like this one:
SELECT * FROM wp_posts WHERE post_content LIKE '%ancien-domaine%';
- If you have many entries to modify, use the WP-CLI
wp search-replace command, which replaces the old address throughout the database while respecting serialized data (see Manage a WordPress site from the command line (WP-CLI)). Do not use a third-party script uploaded to the server: forgotten after use, it becomes an entry point for an attacker.
Step 4: Clear the cache
If you use a caching plugin or a CDN (such as Cloudflare), clear their cache so that the changes take effect.
- Temporarily disable any caching plugin (e.g., WP Super Cache, W3 Total Cache).
- If you use Cloudflare or another CDN, clear their cache via their dashboard.
- Reload your site to check if the issue is resolved.
Step 5: Check the .htaccess file
A misconfigured .htaccess file can also cause redirects to the old domain.
- Access the
.htaccess file located in the WordPress root directory.
- Save a copy before modifying anything.
- Replace only the block between
# BEGIN WordPress and # END WordPress with this one (default configuration). Do not touch the other rules in the file (cache, HTTPS redirect, security):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- Save and upload the file to the server.
Step 6: Test your site
- Open a browser in incognito mode or clear your browser cache.
- Access your site via its main domain to check if everything works correctly.
- Test several pages to ensure that all redirects point to the correct domain.
Going further