Plesk – move aliases to different domain

If you have read my article Plesk – get information about aliases you already know how to determine the aliases in the system.

To get a list of configured domains, you can use the following query after connecting to the Plesk database via key:

mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa
mysql> select * from domains;

This will give you something like that:

+----+------------+-----------------------------------+-----------------------------------+-------------+--------+---------+--------------+-------+-------------+-----------+-----------+--------------------------------------+-------------+---------+-----------+-----------+-------------+-----------------+----------------+----------------+------------------+---------------------+-------------+-----------+-----------+
| id | cr_date    | name                              | displayName                       | dns_zone_id | status | htype   | real_size    | cl_id | cert_rep_id | limits_id | params_id | guid                                 | external_id | overuse | gl_filter | vendor_id | webspace_id | webspace_status | parentDomainId | permissions_id | adminDescription | resellerDescription | description | icpStatus | icpPermit |
+----+------------+------------------------------------+----------------------------------+-------------+--------+---------+--------------+-------+-------------+-----------+-----------+--------------------------------------+-------------+---------+-----------+-----------+-------------+-----------------+----------------+----------------+------------------+---------------------+-------------+-----------+-----------+
|  1 | 2014-12-08 | preview.asksheldon.de             | preview.asksheldon.de             |           2 |      0 | vrt_hst |  12785790976 |     1 |           0 |         0 |         0 | 6bb68df0-c4b7-4d0a-8111-7c06015b03ec |             | false   | on        |         1 |           0 |               0 |              0 |              0 | NULL             | NULL                | NULL        |         0 | NULL      |
|  2 | 2014-12-08 | zmp.asksheldon.de                 | zmp.asksheldon.de                 |           3 |     16 | vrt_hst | 253433241600 |     1 |           2 |         0 |         0 | 01103186-8f53-44b3-ba70-6dfaa659d681 |             | false   | on        |         1 |           0 |               0 |              0 |              0 | NULL             | NULL                | NULL        |         0 | NULL      |
|  3 | 2015-09-28 | asksheldon.asksheldon.de          | asksheldon.asksheldon.de          |           6 |      0 | vrt_hst |  86978876076 |     1 |           3 |         0 |         0 | 2097dbfe-c28b-4ac1-9924-431b1fa950ca |             | false   | on        |         1 |           0 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  4 | 2016-02-16 | asksheldonstage.asksheldon.de     | asksheldonstage.asksheldon.de     |           7 |      0 | vrt_hst |  31841124352 |     1 |           4 |         0 |         0 | b7011bd3-01fd-40ef-a217-c6624d765781 |             | false   | on        |         1 |           0 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  5 | 2016-02-16 | asksheldondev.asksheldon.de       | asksheldondev.asksheldon.de       |           8 |      0 | vrt_hst |  27434414080 |     1 |           5 |         0 |         0 | 5c82a626-491d-45e2-a693-1a738ff81a99 |             | false   | on        |         1 |           0 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  6 | 2016-02-22 | asksheldon-cms.asksheldon.de      | asksheldon-cms.asksheldon.de      |           9 |      0 | vrt_hst |      5287936 |     1 |           0 |         0 |         0 | cfc6c982-bb8b-4e93-8ce8-2a962d2554e3 |             | false   | on        |         1 |           3 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  7 | 2016-02-22 | asksheldonstage-cms.asksheldon.de | asksheldonstage-cms.asksheldon.de |          10 |      0 | vrt_hst |      8597504 |     1 |           0 |         0 |         0 | 10872589-24aa-4ffc-93b1-f506fac2b434 |             | false   | on        |         1 |           4 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  8 | 2016-02-22 | asksheldondev-cms.asksheldon.de   | asksheldondev-cms.asksheldon.de   |          11 |      0 | vrt_hst |      4943872 |     1 |           0 |         0 |         0 | f1c7a0fc-94d6-40a6-b53a-772a009edc07 |             | false   | on        |         1 |           5 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
|  9 | 2016-09-20 | cb.asksheldon.de                  | cb.asksheldon.de                  |          19 |      0 | vrt_hst |       487424 |     1 |           0 |         0 |         0 | c2f89da8-8114-4aa9-a5d8-b1ac6468ec62 |             | false   | on        |         1 |           0 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
| 10 | 2016-09-22 | cb-dev.asksheldon.de              | cb-dev.asksheldon.de              |          20 |      0 | vrt_hst |    790781952 |     1 |           0 |         0 |         0 | f069f835-4823-4e32-bfb2-a20146a9c3ff |             | false   | on        |         1 |           0 |               0 |              0 |              0 |                  |                     |             |         0 | NULL      |
+----+------------+-----------------------------------+-----------------------------------+-------------+--------+---------+--------------+-------+-------------+-----------+-----------+--------------------------------------+-------------+---------+-----------+-----------+-------------+-----------------+----------------+----------------+------------------+---------------------+-------------+-----------+-----------+
10 rows in set (0.00 sec)

What you nee is the id of the parent page that the aliases should be associated with. Now you can simply use the following SQL update query to change the alias association (dom_id have to be the id of the chosen main domain):

UPDATE domain_aliases set dom_id=3 WHERE id IN (2,3,5,6,7,8,13,14);

How you get the IDs to change it described in Plesk – get information about aliases. If you want to delete a alias, have a look at this blogpost: Plesk – remove alias via console

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.