为何/about-us与/about-us-amp指向同一页面?AMP配置咨询
about-us.php Hey there, let's break down why both your regular /about-us and AMP /about-us-amp URLs are landing on the same about-us.php file. Here are the most likely causes to investigate:
Incorrect Server Rewrite Rules
This is the #1 culprit for this kind of routing mix-up. If you're using Apache with.htaccess, or Nginx with server block configs, your rewrite rules might be too broad and matching both URLs. For example, an Apache rule like this would catch both/about-usand/about-us-amp:RewriteRule ^about-us(.*)$ about-us.php [L]Fix it by creating separate, precise rules for each URL:
RewriteRule ^about-us$ about-us.php [L] RewriteRule ^about-us-amp$ about-us-amp.php [L]For Nginx, double-check your
locationblocks to ensure/about-us-ampis mapped to the correct PHP file instead of falling back to the regular page.CMS/Framework Routing Misconfiguration
If you're using a CMS like WordPress or a framework like Laravel, your routing setup might be mapping both URLs to the same controller or template. For example, in WordPress, a custom route or misconfigured AMP plugin could be forcing the AMP URL to use the regular page's template file instead ofabout-us-amp.php.Missing or Misplaced AMP File
Double-check thatabout-us-amp.phpactually exists in the correct directory on your server. A typo in the filename (likeabout-us-amp.pgpinstead of.php) or placing it in the wrong subfolder could cause the server to fall back to the existingabout-us.phpfile as a default.Cached Route Data
Server-side caching (like OPcache, APCu) or a CDN might be holding onto old routing rules. Try clearing all caches on your server, purging your CDN cache, and testing the URLs in an incognito browser window to rule out cached responses.
Start with verifying your server rewrite rules—they're usually the easiest fix. If that doesn't resolve it, work through the other checks one by one.
内容的提问来源于stack exchange,提问作者janjua

