> For the complete documentation index see https://domscan.net/llms.txt. Markdown versions of every docs page are available by appending .md to the page URL.

Source: https://domscan.net/ar/docs/redirect-chain

# سلسلة إعادة التوجيه

باستخدام DomScan API، اتبع سلاسل إعادة توجيه URL لكشف ترقيات HTTPS وتغييرات المجالات والصفحات المقصودة النهائية.

اتبع سلاسل إعادة توجيه URL لكشف ترقيات HTTPS وتغييرات المجالات والصفحات المقصودة النهائية. مفيد لتحليل SEO والتدقيق الأمني وفهم توجيه URL. تتبع جميع عمليات إعادة التوجيه 3xx بما فيها 301 و 302 و 303 و 307 و 308.

GET /v1/redirects

#### معاملات الاستعلام

| المعامل | النوع | Description |
| --- | --- | --- |
| url مطلوب | string | عنوان URL الابتدائي المراد متابعته (على سبيل المثال، "http://example.com") |
| max_redirects اختياري | number | الحد الأقصى لعمليات إعادة التوجيه للمتابعة (الافتراضي: 10، الحد الأقصى: 20) |
| domain اختياري | string | بديل لـ url عندما تكون لديك نطاق عاري فقط. يفوز معامل url عند توفير كلاهما، و https:// يُضاف تلقائياً. |

#### حقول الرد

| الحقل | النوع | Description |
| --- | --- | --- |
| `original_url` | string | عنوان URL الابتدائي الذي تم توفيره |
| `final_url` | string | عنوان URL النهائي بعد جميع عمليات إعادة التوجيه |
| `redirect_count` | number | إجمالي عدد عمليات إعادة التوجيه المتابعة |
| `https_upgrade` | boolean | ما إذا تم ترقية HTTP إلى HTTPS |
| `chain` | array | كل إعادة توجيه مع عنوان URL وكود الحالة والموقع |

#### طلب مثال

```bash
curl -H "X-API-Key: your-api-key" "https://domscan.net/v1/redirects?url=http://github.com"
```

```javascript
const domscanFetch = (url, options = {}) =>
  fetch(url, {
    ...options,
    headers: { ...options.headers, "X-API-Key": "your-api-key" },
  });

const response = await domscanFetch(
  "https://domscan.net/v1/redirects?url=" + encodeURIComponent("http://github.com")
);
const data = await response.json();

console.log(`Final URL: ${data.final_url}`);
console.log(`Redirects: ${data.redirect_count}`);
console.log(`HTTPS upgrade: ${data.https_upgrade}`);

data.chain.forEach((hop, i) => {
  console.log(`${i + 1}. ${hop.status} ${hop.url} → ${hop.location}`);
});
```

```python
import requests

domscan = requests.Session()
domscan.headers.update({"X-API-Key": "your-api-key"})

from urllib.parse import quote

url = quote("http://github.com", safe='')
response = domscan.get(f"https://domscan.net/v1/redirects?url={url}")
data = response.json()

print(f"Final URL: {data['final_url']}")
print(f"HTTPS upgrade: {data['https_upgrade']}")
for i, hop in enumerate(data['chain']):
    print(f"{i+1}. [{hop['status']}] {hop['url']}")
```

#### مثال الرد

```json
{
  "original_url": "http://github.com",
  "final_url": "https://github.com/",
  "redirect_count": 1,
  "chain": [
    {
      "url": "http://github.com",
      "status": 301,
      "location": "https://github.com/",
      "response_time_ms": 45
    }
  ],
  "https_upgrade": true,
  "domain_change": false,
  "total_time_ms": 156
}
```
