Redirects API
De Redirects API biedt endpoints voor het beheren van URL redirects in Joomla.
Base URL
/api/index.php/v1/redirects
Endpoints Overzicht
| Methode | Endpoint | Beschrijving |
|---|---|---|
| GET | /redirects | Alle redirects ophalen |
| GET | /redirects/{id} | Specifieke redirect ophalen |
| POST | /redirects | Nieuwe redirect aanmaken |
| PATCH | /redirects/{id} | Redirect bijwerken |
| DELETE | /redirects/{id} | Redirect verwijderen |
Alle redirects ophalen
GET /api/index.php/v1/redirects
Response
{
"data": [
{
"type": "redirects",
"id": "1",
"attributes": {
"old_url": "/oude-pagina",
"new_url": "/nieuwe-pagina",
"referer": "",
"comment": "Pagina verhuisd",
"hits": 25,
"published": 1,
"created_date": "2024-01-15 10:30:00",
"modified_date": "2024-01-15 10:30:00",
"header": 301
}
}
]
}
Specifieke redirect ophalen
GET /api/index.php/v1/redirects/{id}
Parameters
| Parameter | Type | Beschrijving |
|---|---|---|
| id | integer | Redirect ID |
Voorbeeld
curl -X GET "https://jouwesite.nl/api/index.php/v1/redirects/1" \
-H "X-Joomla-Token: JOUW_API_TOKEN"
Redirect aanmaken
POST /api/index.php/v1/redirects
Request Body
{
"old_url": "/oude-url",
"new_url": "/nieuwe-url",
"comment": "Pagina verplaatst naar nieuwe locatie",
"published": 1,
"header": 301
}
Verplichte velden
| Veld | Type | Beschrijving |
|---|---|---|
| old_url | string | Oude URL pad |
| new_url | string | Nieuwe URL pad |
Optionele velden
| Veld | Type | Standaard | Beschrijving |
|---|---|---|---|
| comment | string | "" | Commentaar/notitie |
| published | int | 1 | Actief (0=nee, 1=ja) |
| header | int | 301 | HTTP redirect code |
Voorbeeld
curl -X POST "https://jouwesite.nl/api/index.php/v1/redirects" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"old_url": "/blog/oud-artikel",
"new_url": "/nieuws/nieuw-artikel",
"comment": "Blog naar nieuws verplaatst",
"header": 301
}'
Redirect bijwerken
PATCH /api/index.php/v1/redirects/{id}
Request Body
{
"new_url": "/andere-nieuwe-url",
"header": 302
}
Voorbeeld
curl -X PATCH "https://jouwesite.nl/api/index.php/v1/redirects/1" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"new_url": "/andere-url",
"comment": "URL aangepast"
}'
Redirect verwijderen
DELETE /api/index.php/v1/redirects/{id}
Voorbeeld
curl -X DELETE "https://jouwesite.nl/api/index.php/v1/redirects/1" \
-H "X-Joomla-Token: JOUW_API_TOKEN"
HTTP Redirect Codes
| Code | Type | Beschrijving |
|---|---|---|
| 301 | Moved Permanently | Permanente redirect (SEO-vriendelijk) |
| 302 | Found | Tijdelijke redirect |
| 303 | See Other | Redirect na POST request |
| 307 | Temporary Redirect | Tijdelijk, behoudt HTTP methode |
| 308 | Permanent Redirect | Permanent, behoudt HTTP methode |
Beste praktijk
Gebruik 301 voor permanente verhuizingen (SEO waarde wordt overgedragen) en 302 voor tijdelijke redirects.
Redirect States
| Waarde | Status |
|---|---|
| -2 | Prullenbak |
| 0 | Niet actief |
| 1 | Actief |
| 2 | Gearchiveerd |
URL Formaat
Relatieve URLs (aanbevolen)
{
"old_url": "/oude-pagina",
"new_url": "/nieuwe-pagina"
}
Absolute URLs
{
"old_url": "https://jouwesite.nl/oude-pagina",
"new_url": "https://jouwesite.nl/nieuwe-pagina"
}
Externe redirect
{
"old_url": "/externe-link",
"new_url": "https://externe-site.nl/pagina"
}
Filtering
Op publicatiestatus
GET /api/index.php/v1/redirects?filter[published]=1
Op HTTP code
GET /api/index.php/v1/redirects?filter[header]=301
Zoeken
GET /api/index.php/v1/redirects?filter[search]=blog
Bulk Redirects Aanmaken
#!/bin/bash
# Bulk redirects aanmaken vanuit CSV
while IFS=',' read -r old new comment; do
curl -X POST "https://jouwesite.nl/api/index.php/v1/redirects" \
-H "X-Joomla-Token: JOUW_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"old_url\": \"$old\",
\"new_url\": \"$new\",
\"comment\": \"$comment\",
\"header\": 301
}"
done < redirects.csv
Statistieken
Elke redirect houdt het aantal hits bij in het hits veld. Dit is nuttig om te zien welke oude URLs nog steeds bezocht worden.
Meest gebruikte redirects
GET /api/index.php/v1/redirects?list[ordering]=hits&list[direction]=desc
info
Het redirect component moet ingeschakeld zijn in Joomla voor redirects om te werken. Controleer dit via System → Plugins → System - Redirect.