域名停放异常自动跳转至主域名,脚本代码修改咨询
Hey there, let's walk through the most common script/configuration culprits causing this automatic redirect, and how to tweak them to get your domain parking working as intended:
1. Check your .htaccess file (Apache servers)
This is the #1 spot for unintended redirects. Open the .htaccess file in the root directory of domain.com and look for lines like:
RewriteEngine On RewriteRule ^(.*)$ https://domain.ir/$1 [R=301,L]
If you find rules like this (especially with R=301 or R=302), comment them out (add a # at the start of the line) or delete them entirely. For proper domain parking, your .htaccess should either be empty (pointing to your parking page) or have only rules needed to serve your static parking content—no redirect directives.
2. Inspect root index files (index.html, index.php, etc.)
Your domain’s default landing file might have hardcoded redirects:
- PHP files: Look for a
header()redirect like this:
Delete these lines to stop the redirect.header("Location: https://domain.ir"); exit; - HTML files: Check for a meta refresh tag:
Remove this tag entirely.<meta http-equiv="refresh" content="0; url=https://domain.ir"> - JavaScript: Look for client-side redirect code:
Delete this script block to prevent the browser from jumping to the other domain.window.location.href = "https://domain.ir";
3. Check CMS/website platform settings (if using one)
If you’re using a CMS like WordPress, Drupal, or similar:
- In WordPress, go to Settings → General and verify that both "WordPress Address (URL)" and "Site Address (URL)" are set to
domain.com(notdomain.ir). If they’re pointing to the.irdomain, update them to match your parked domain. - Disable any redirect plugins (like "Redirection" or Yoast SEO redirect rules) that might be forcing the jump to
domain.ir. - For other platforms, look for "domain settings" or "redirect management" sections to turn off cross-domain redirects.
4. Verify Nginx server configuration (if using Nginx)
If your host uses Nginx instead of Apache, check the server block config for domain.com (usually in /etc/nginx/sites-available/ or similar) for lines like:
return 301 https://domain.ir$request_uri;
Or rewrite rules that redirect traffic. Comment out or delete these lines, then restart Nginx to apply changes.
Final Tip
After making changes, clear your browser’s cache (301 redirects are cached aggressively!) or test in incognito mode to confirm the redirect is gone and your parking page loads correctly.
内容的提问来源于stack exchange,提问作者ehsan kobraei

