Laravel Forge JavaScript SDK
Redirect Rules
Redirect Rules
Create a redirect rule
Method
forge.redirect.create(server_id, site_id, payload)
Usage
1const forge = new Forge('API_TOKEN');23const redirectRule = await forge.redirect.create(server_id, site_id, payload);
Payload
1{2 from: '/docs',3 to: '/docs/1.1',4 type: 'redirect'5}
Redirect Types
Type | Description |
---|---|
redirect | Creates a temporary 302 redirect. |
permanent | Create a permanent 301 redirect. |
Example Response
1{2 "redirect_rule": {3 "id": 15,4 "from": "/docs",5 "to": "/docs/1.1",6 "type": "redirect",7 "created_at": "2018-03-07 16:33:20"8 }9}
List redirect rules
Method
forge.redirect.list(server_id, site_id)
Usage
1const forge = new Forge('API_TOKEN');23const redirectRules = await forge.redirect.list(server_id, site_id);
Example Response
1{2 "redirect_rules": [3 {4 "id": 15,5 "from": "/docs",6 "to": "/docs/1.1",7 "type": "redirect",8 "created_at": "2018-03-07 16:33:20"9 }10 ]11}
Get a redirect rule
Method
forge.redirect.get(server_id, site_id, rule_id)
Usage
1const forge = new Forge('API_TOKEN');23const redirectRule = await forge.redirect.get(server_id, site_id, rule_id);
Example Response
1{2 "redirect_rule": {3 "id": 15,4 "from": "/docs",5 "to": "/docs/1.1",6 "type": "redirect",7 "created_at": "2018-03-07 16:33:20"8 }9}
Delete a redirect rule
Method
forge.redirect.delete(server_id, site_id, rule_id)
Usage
1const forge = new Forge('API_TOKEN');23await forge.redirect.delete(server_id, site_id, rule_id);
Edit this page on GitHub