mirror of
https://github.com/ovh/php-ovh.git
synced 2023-11-05 03:20:26 +01:00
Fix typo
Signed-off-by: Vincent Casse <vincent.casse@corp.ovh.com>
This commit is contained in:
parent
aded4f28f7
commit
42c0a43c4b
@ -1,12 +1,12 @@
|
|||||||
How to get web hosting capabilities using php wrapper?
|
How to create HTTP redirection using php wrapper?
|
||||||
----------------------------------------------------
|
-------------------------------------------------
|
||||||
|
|
||||||
This documentation will help you to create an HTTP redirection from a subdomain to another domain. Following script include DNS record check and delete record if their will conflict with your redirection!
|
This documentation will help you to create an HTTP redirection from a subdomain to another domain. Following script include DNS record check and delete record if their will conflict with your redirection!
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Having PHP 5.2+
|
- Having PHP 5.2+
|
||||||
- Having a dns record at OVH
|
- Having a DNS zone at OVH
|
||||||
|
|
||||||
## Download PHP wrapper
|
## Download PHP wrapper
|
||||||
|
|
||||||
@ -25,7 +25,8 @@ tar xzvf php-ovh-2.0.0-with-dependencies.tar.gz
|
|||||||
|
|
||||||
## Create a new token
|
## Create a new token
|
||||||
|
|
||||||
You can create a new token using this url: [https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*](https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*). Keep application key, application secret and consumer key to complete the script.
|
You can create a new token using this url: [https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*](https://api.ovh.com/createToken/?GET=/domain/zone/*&POST=/domain/zone/*&DELETE=/domain/zone/*).
|
||||||
|
Keep application key, application secret and consumer key to complete the script.
|
||||||
|
|
||||||
Be warned, this token is only valid for this script on **/domain/zone/\*** APIs.
|
Be warned, this token is only valid for this script on **/domain/zone/\*** APIs.
|
||||||
If you need a more generic token, you may adjust the **Rights** fields at your needs.
|
If you need a more generic token, you may adjust the **Rights** fields at your needs.
|
||||||
|
@ -32,16 +32,19 @@ try {
|
|||||||
// check if dns record are available
|
// check if dns record are available
|
||||||
$recordIds = $conn->get('/domain/zone/' . $domain . '/record?subDomain='. $subDomain );
|
$recordIds = $conn->get('/domain/zone/' . $domain . '/record?subDomain='. $subDomain );
|
||||||
|
|
||||||
|
// If subdomain is not defined, we don't want to delete all A, AAAA and CNAME records
|
||||||
|
if ( isset($subDomain) ) {
|
||||||
foreach ($recordIds as $recordId) {
|
foreach ($recordIds as $recordId) {
|
||||||
$record = $conn->get('/domain/zone/' . $domain . '/record/' . $recordId);
|
$record = $conn->get('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||||
|
|
||||||
// If record include A, AAAA or CNAME for subdomain asked, we delete it
|
// If record include A, AAAA or CNAME for subdomain asked, we delete it
|
||||||
if ( in_array( $record['fieldType'], array( 'A', 'AAAA', 'CNAME' ) ) ) {
|
if ( in_array( $record['fieldType'], array( 'A', 'AAAA', 'CNAME' ) ) ) {
|
||||||
|
|
||||||
echo "We will delete field " . $record['fieldType'] . " for " . $record['zone'] . PHP_EOL;
|
echo "We will delete field " . $record['fieldType'] . " for " . $record['subDomain'] . $record['zone'] . PHP_EOL;
|
||||||
$conn->delete('/domain/zone/' . $domain . '/record/' . $recordId);
|
$conn->delete('/domain/zone/' . $domain . '/record/' . $recordId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Now, we are ready to create our new redirection
|
// Now, we are ready to create our new redirection
|
||||||
$redirection = $conn->post('/domain/zone/' . $domain . '/redirection', array(
|
$redirection = $conn->post('/domain/zone/' . $domain . '/redirection', array(
|
||||||
|
Loading…
Reference in New Issue
Block a user