Create site redirect rules from CSV
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mode\"\r\n\r\nappend\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form mode=appendconst form = new FormData();
form.append('file', '<string>');
form.append('mode', 'append');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mode\"\r\n\r\nappend\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"imported": 123,
"invalid": [
{
"line": "<string>",
"reason": "<string>",
"from": "<string>",
"to": "<string>",
"type": "<string>"
}
],
"duplicates": [
{
"line": "<string>",
"reason": "Repeats an earlier row in the file.",
"from": "<string>",
"to": "<string>",
"type": "<string>"
}
]
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Redirect Rules
Create site redirect rules from CSV
Import rules from a CSV with a from,to,type header. Append adds to the existing rules, replace swaps them all out. Invalid and duplicate rows are skipped and reported.
Processing mode: async
POST
/
orgs
/
{organization}
/
servers
/
{server}
/
sites
/
{site}
/
redirect-rules
/
import
Create site redirect rules from CSV
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mode\"\r\n\r\nappend\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}curl --request POST \
--url https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file=@example-file \
--form mode=appendconst form = new FormData();
form.append('file', '<string>');
form.append('mode', 'append');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://forge.laravel.com/api/orgs/{organization}/servers/{server}/sites/{site}/redirect-rules/import"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mode\"\r\n\r\nappend\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"imported": 123,
"invalid": [
{
"line": "<string>",
"reason": "<string>",
"from": "<string>",
"to": "<string>",
"type": "<string>"
}
],
"duplicates": [
{
"line": "<string>",
"reason": "Repeats an earlier row in the file.",
"from": "<string>",
"to": "<string>",
"type": "<string>"
}
]
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Authorizations
The access token received from the authorization server in the OAuth 2.0 flow.
FlowAuthorization Code
- Authorization URL
- https://forge.laravel.com/oauth/authorize
- Token URL
- https://forge.laravel.com/oauth/token
Scopes1
site:manage-redirects
Allow members to configure URL redirects
Path Parameters
The organization slug
The server ID
The site ID
Body
multipart/form-data
Was this page helpful?