Why do I see a 404 page when testing an affiliate link?

Have you encountered a 404 error while testing an affiliate link with a pretty URL structure, such as /ref/123 or /ref/john? This issue can be frustrating, but it’s usually caused by WordPress’ rewrite rules or a conflict with your site’s settings.

In this guide, we’ll walk you through the steps to troubleshoot and resolve this problem.

Troubleshooting Pretty URLs

When affiliate links return a 404 error, the most common solution is to flush WordPress’ rewrite rules. To do this, navigate to Settings » Permalinks in your WordPress dashboard. Without changing any settings, click the Save Changes button. This simple action refreshes WordPress’ permalink structure and often resolves the issue. Once you’ve saved your permalinks, test the affiliate referral URL again to see if the error is resolved.

If the problem persists, the next step is to re-save AffiliateWP’s General settings. Go to AffiliateWP » Settings » General, scroll to the bottom of the page, and click Save Changes. This ensures that AffiliateWP’s URL settings are correctly applied to your site. After re-saving the settings, test the affiliate link again.

Another common cause of 404 errors is cached data. Clear your browser cache and, if you’re using a caching plugin, clear your site’s cache as well. Caching issues can sometimes interfere with the display of updated URLs, so this step is crucial for accurate testing.

Testing for Plugin Conflicts

If flushing permalinks, re-saving settings, and clearing your cache don’t resolve the 404 error, it might be due to a plugin conflict. To diagnose this, temporarily deactivate all plugins on your site except for AffiliateWP. Then, repeat the permalink flushing steps by going to Settings » Permalinks and clicking Save Changes. Test your affiliate links again to see if they work correctly. If the links function properly without other plugins active, you can reactivate your plugins one by one to identify which one is causing the conflict.

If pretty URLs still aren’t working, you can try changing your permalink structure in WordPress. Go to Settings » Permalinks and select a structure like Post Name, which is compatible with pretty URLs. Be cautious when changing your permalink structure, as this can affect existing links to your website.

If your site is already established, changing the permalink structure may break links on third-party websites or bookmarks saved by visitors. To avoid losing traffic, consider using a redirect plugin to guide users from old links to your updated structure. Many plugins are available on the WordPress repository to help you set up redirects effectively. If you’re still building your website and prefer pretty URLs, setting the desired permalink structure from the start is the best way to prevent these issues.

If you decide to change your permalink structure, be aware that it can have significant consequences for an established website. Broken links can impact user experience and search engine rankings if not handled properly. Always set up URL redirects if you’re changing from an older structure to a pretty URL format. For new sites, it’s best to select your preferred permalink structure early on to avoid these challenges.

Frequently Asked Questions

Why do pretty URLs stop working?

Pretty URLs can stop working due to issues with WordPress’ rewrite rules, plugin conflicts, or incorrect permalink settings. Flushing your permalinks often resolves the problem by resetting the rewrite rules.

How do I flush WordPress’ rewrite rules?

To flush the rewrite rules, go to Settings » Permalinks in your WordPress dashboard and click Save Changes without making any changes. This process refreshes your URL structure.


That’s it! 404 errors with affiliate links can often be resolved by flushing permalinks, clearing caches, or diagnosing plugin conflicts. Taking steps like adjusting your permalink structure or ensuring proper redirects can also prevent further issues. If the problem persists, AffiliateWP’s support team is available to help ensure your affiliate links work as expected, keeping your program running smoothly.