diff --git a/.gitignore b/.gitignore
index c871c2c5..3c668233 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,4 @@ bureau/locales/fr_FR/LC_MESSAGES/messages.po~
bureau/locales/it_IT/LC_MESSAGES/messages.po~
bureau/locales/nl_NL/LC_MESSAGES/messages.po~
bureau/locales/pt_BR/LC_MESSAGES/messages.po~
+.tx/alternc.alternc
diff --git a/debian/alternc.cron.d b/debian/alternc.cron.d
index f324f260..0929f5fc 100644
--- a/debian/alternc.cron.d
+++ b/debian/alternc.cron.d
@@ -14,8 +14,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 5 * * * alterncpanel /usr/lib/alternc/sqlbackup.sh -t daily
0 4 * * 0 alterncpanel /usr/lib/alternc/sqlbackup.sh -t weekly
-# Every 5 minutes, spool waiting domain changes
-*/5 * * * * root /usr/lib/alternc/update_domains.sh
+# Every minute, spool waiting domain changes
+* * * * * root /usr/lib/alternc/update_domains.php
# Every 5 minutes, do mails actions
*/5 * * * * root /usr/lib/alternc/update_mails.sh
diff --git a/etc/alternc/templates/alternc/bureau.conf b/etc/alternc/templates/alternc/bureau.conf
index 6d677e87..d834648b 100644
--- a/etc/alternc/templates/alternc/bureau.conf
+++ b/etc/alternc/templates/alternc/bureau.conf
@@ -5,10 +5,6 @@
DocumentRoot /usr/share/alternc/panel/admin
ServerName %%fqdn%%
- # Mail autoconfig
- ServerAlias autoconfig.*
- ServerAlias autodiscover.*
-
RewriteEngine on
RewriteRule ^/admin/(.*) /$1 [R=301,L]
@@ -17,20 +13,6 @@
RewriteEngine On
RewriteRule ^webmail /webmail-redirect.php [L]
- # Mail autoconfig
- RewriteRule ^/mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
- RewriteRule ^/mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
- RewriteRule ^mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
- RewriteRule ^mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
- RewriteRule ^/autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
- RewriteRule ^/Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
- RewriteRule ^/Autodiscover.xml$ mailautoconfig_outlook.php [L]
- RewriteRule ^/autodiscover.xml$ mailautoconfig_outlook.php [L]
- RewriteRule ^autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
- RewriteRule ^Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
- RewriteRule ^Autodiscover.xml$ mailautoconfig_outlook.php [L]
- RewriteRule ^autodiscover.xml$ mailautoconfig_outlook.php [L]
-
# will be used to define aliases such as /javascript /webmail /squirrelmail ...
IncludeOptional /etc/alternc/apache-panel.d/*.conf
diff --git a/etc/alternc/templates/apache2/autodiscover-both.conf b/etc/alternc/templates/apache2/autodiscover-both.conf
new file mode 100644
index 00000000..123a09f3
--- /dev/null
+++ b/etc/alternc/templates/apache2/autodiscover-both.conf
@@ -0,0 +1,53 @@
+
+
+ DocumentRoot /usr/share/alternc/panel/admin
+
+ AssignUserId alterncpanel alterncpanel
+ SetEnv LOGIN "0000-panel"
+
+ ServerName %%fqdn%%
+
+ # Mail autoconfig
+ RewriteRule ^/mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^/mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^/autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^/Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^/Autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^/autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^Autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^autodiscover.xml$ mailautoconfig_outlook.php [L]
+
+
+
+
+ DocumentRoot /usr/share/alternc/panel/admin
+
+ AssignUserId alterncpanel alterncpanel
+ SetEnv LOGIN "0000-panel"
+
+ ServerName %%fqdn%%
+
+ # Mail autoconfig
+ RewriteRule ^/mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^/mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^mail/mailautoconfig.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^mail/config-v1.1.xml$ /mailautoconfig_thunderbird.php [L]
+ RewriteRule ^/autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^/Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^/Autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^/autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^autodiscover/autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^Autodiscover/Autodiscover.xml$ /mailautoconfig_outlook.php [L]
+ RewriteRule ^Autodiscover.xml$ mailautoconfig_outlook.php [L]
+ RewriteRule ^autodiscover.xml$ mailautoconfig_outlook.php [L]
+
+ SSLEngine On
+ SSLCertificateFile %%CRT%%
+ SSLCertificateKeyFile %%KEY%%
+ %%CHAINLINE%%
+
+
diff --git a/src/update_domains.php b/src/update_domains.php
new file mode 100644
index 00000000..8589e55e
--- /dev/null
+++ b/src/update_domains.php
@@ -0,0 +1,10 @@
+#!/usr/bin/php -q
+update_domains();
+