如何解决GoDaddy域名转发至WordPress子域名后内链显示子域名问题
Hey there, let’s work through this problem together. The core issue here is that masked (frame) forwarding only hides the subdomain URL in the address bar on the initial load—WordPress is still configured to use sub.mydomain.it as its site URL, so all internal links pull that address instead of your main www.domain.com. Here’s how to fix this properly:
Step 1: Update WordPress Site URLs
First, you need to tell WordPress to use your main domain as its official address. You can do this in a couple of ways:
Option A: Via WordPress Admin Dashboard
- Log into your WordPress backend at
sub.mydomain.it/wp-admin - Navigate to Settings → General
- Update both WordPress Address (URL) and Site Address (URL) to
https://www.domain.com - Save your changes, then clear your browser’s cache and test internal links
Option B: Via wp-config.php (if you can’t access the dashboard)
- Log into your Netsons hosting control panel, open the file manager, and navigate to your WordPress installation directory
- Locate the
wp-config.phpfile and edit it - Add these two lines right before the
/* That's all, stop editing! Happy publishing. */comment:define('WP_HOME','https://www.domain.com'); define('WP_SITEURL','https://www.domain.com'); - Save the file, clear cache, and test links
Step 2: Clean Up Old Subdomain References in Content
Even after updating the site URLs, you might have hardcoded links in posts/pages or metadata that still point to the subdomain. Fix this with one of these methods:
Option A: Use a Search-Replace Plugin
- Install a plugin like Better Search Replace (find it directly in the WordPress plugin directory)
- Set the "Search for" field to
https://sub.mydomain.itand "Replace with" tohttps://www.domain.com - Select all relevant database tables (usually starting with
wp_unless you changed the prefix) - Run the replacement, then clear any WordPress cache plugins you’re using
Option B: Use phpMyAdmin (Advanced)
- Access phpMyAdmin through your Netsons control panel
- Select your WordPress database
- Run these SQL queries (replace
wp_with your actual table prefix):UPDATE wp_posts SET post_content = REPLACE(post_content, 'https://sub.mydomain.it', 'https://www.domain.com'); UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'https://sub.mydomain.it', 'https://www.domain.com');
Step 3: (Optional) Ditch Masked Forwarding for a Better Long-Term Solution
Masked forwarding relies on an iframe to display your site, which can cause SEO issues, cookie problems, and unexpected link behavior. A more reliable setup is to point your main domain directly to your Netsons hosting:
- In GoDaddy’s DNS manager, update the
wwwrecord:- If using a CNAME: Point
www.domain.comtosub.mydomain.it - If using an A record: Point
www.domain.comto your Netsons server’s IP address
- If using a CNAME: Point
- In your Netsons control panel, add
www.domain.comas an addon domain, and set its document root to your existing WordPress installation directory - Remove the masked forwarding rule from GoDaddy—now your main domain will serve the site directly, with all links showing the correct URL
Don’t forget to clear all caches (browser, WordPress cache plugins, and any CDN you might use) after making these changes to ensure the updates take effect immediately.
内容的提问来源于stack exchange,提问作者Fabio Politi

