I think this can interrest someone: It used to drive me crazy have user names in format http://www.domain.tld/users/webXX_user wanted them as http://user.domain.tld (third level domain) so here is how to do it 1. in Ispconfig go to Management->System Config->Settings->ISP manager change User Prefix to [DOMAIN]_ then user dirs will lok like http://www.domain.tld/users/domain.tld_user 2. Create file /etc/httpd/user_rewrite.conf which includes RewriteCond %{SERVER_NAME} !^www\. RewriteCond %{SERVER_NAME} !^mail\. ( not neccessary see bellow) RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$ RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L] You can create as many lines like "RewriteCond %{SERVER_NAME} !^www\." as you want ^www\. here means that www.domain.tld will not rewrite (will not be looking for directory http://www.domain.tld/users/domain.tld_www, but show www.domain.tld) In my case i'm using also rewrite to show webmail as mail.domain.tld for each domain so i also have RewriteCond %{SERVER_NAME} !^mail\. 3. In ISP manager->sites click on your site, then go to "Co-domains" and add yourIP * domain.tld 6 In ISPmanger->sites-> www.domain.tld ->Basic put "Include user_rewrite.conf" into Apache Directives (Optional): If you have more domains and don't want to forget do this for each domain, change: Management->Form Designer->Edit Form->isp - ISP Web:->edit->web_httpd_include->Edit and put Include user_rewrite.conf into Default: window 5. In DNS manager ->domain.tld-> records you must create CNAME * domain.tld 6. probably not necessary, but you can restart apache "apachectl restart" and you are done ============= If you want to have mail.domain.tld for each domain showing your default webmail must have in DNS for your site CNAME mail yourwebmail.yourdomain.tld and your /etc/httpd/user_rewrite.conf should look like this RewriteEngine on RewriteCond %{SERVER_NAME} ^mail.*.*$ RewriteRule .* /var/www/path_to_your_webmail_site/web$0 [L] RewriteCond %{SERVER_NAME} !^www\. RewriteCond %{SERVER_NAME} !^www2\. RewriteCond %{SERVER_NAME} !^mysql2\. RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$ RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L] It works for me, i have configured webmail outside ISPconfig apache, if you use some webmail inside ispconfig in /home/admispconfig/ispconfig/web/yourwebmail it may not work (haven't tried) Just have 2 questions for Falco or some other developer here .) 1. is there more ellegant way how to include user_rewrite.conf for all domains? It didnt work for me to include in httpd.conf for all domains at once, its working just when included for each Virtual Host separatelly 2. Can i change default DNS entry for domains without editing code? In my case i like to have DNS for all domains by default like this: A Record empty (domain.tld is already included in zone file but not showed in DNS manager) CNAME Hostname Target * mydomain.tld mail mail.myhosting.tld MX Mailserver Hostname mail.myhosting.tld mailbackup.myhosting.tld (by default it shows MX admin.myhosting.tld which is wrong for me i have admin on different ip adress then users webs)
better one rewrite thru http:// in previous post makes not neccessary overhead, better one will be rewrite on filesystem: RewriteRule ^/(.*)$ /var/www/www.%2/user/%2_%1/web/$1 [L] it should be nice to have it in /etc/httpd/conf/vhosts/Vhosts_ispconfig.conf together with AliasMatch ^/~([^/]+)(/(.*))? /var/www/webXX/user/$1/web/$3 AliasMatch ^/users/([^/]+)(/(.*))? /var/www/webXX/user/$1/web/$3 (btw: what are this aliases for?) Is it possible to put it somewhere in the code to create rewrite automatically for each VirtualHost?
Take a look at chapter 2.2.9 on http://ispconfig.org/downloads/manual_en/manual_kunde_en_src.htm#4_2_2 . You can modify the function make_vhost() in /root/ispconfig/scripts/lib/config.lib.php.
default aliases I was just wondering, why you guys use this aliases to make link http://www.domain.tld/users/testuser/ when user directory is var/www/webXX/user/ then you can show it as http://www.domain.tld/user/testuser/ without rewrite.. ?
I dont think that it will work without rewrite. The directory: http://www.domain.tld/users/testuser/ is without rewrite: /var/www/webXX/web/users/testuser/ and not: /var/www/webXX/users/testuser/ The directory of the users is outside of the document root of the website.
Hey Radim, thx for this idea.. I am very interested in getting this setup on my system... I'm trying to follow you're directions but im unclear on the dns/cname directions.. This is what I have done so far: 1) Set users to be created thru [DOMAIN]_ 2) Created file: /etc/apache2/user_rewrite.conf 3) Inserted into user_rewrite.conf: Code: RewriteEngine On RewriteCond %{SERVER_NAME} !^www\. RewriteCond %{SERVER_NAME} !^mail\. RewriteCond %{SERVER_NAME} ^([^.]*)\.(.*\..*)$ RewriteRule ^/(.*)$ http://www.%2/users/%2_%1/$1 [P] 4) Added Include user_rewrite.conf into my sites default apache directives 5) Restarted apache2 6) Created user: serverhash.com_testuser 7) Added CNAME: Code: Hostname Target testuser testuser.serverhash.com Complete DNS setup is as follows: Code: A Record IP-Adresse Hostname 72.148.231.196 www CNAME Hostname Target testuser testuser.serverhash.com MX Mailserver Hostname www.serverhash.com mail.serverhash.com mail Works: http://www.serverhash.com/users/serverhash.com_testuser/ http://www.serverhash.com/~serverhash.com_testuser/ Does not work: http://testuser.serverhash.com/ Can you see anything im doing wrong. any help is appreciated.
Oh, i forget (changed now my first howto a bit) In ISP manager click on your site, then go to "Co-domains" and add yourIP testuser serverhash.com and your CNAME is wrong, it has to be CNAME Hostname Target testuser serverhash.com I preffer add co-domain MyIP * mydomain.tld and have DNS record CNAME Hostname Target * mydomain.tld then you don't have to care about each user apache will process anything.yourdomain.com
Quick question for radmin_h.. When you are creating the co-domain for * example.com are you checking the option for ISPConfig to create the DNS records for you? I'm still having problems with getting it to re-write, using a recently updated ISPConfig setup with the same details from above, i'm including the user_rewrite.conf in the Apache Directives in ISPConfig via: Code: RewriteEngine On Include /etc/apache2/user_rewrite.conf My DNS info for my domain currently: Code: A Record IP-Adresse Hostname 72.148.231.196 www CNAME Hostname Target * serverhash.com MX Mailserver Hostname www.serverhash.com www www.serverhash.com SPF Hostname serverhash.com Does this appear to be correct?
Im not sure about path to user_rewrite.conf I have it in my apache ServerRoot (which is /etc/httpd check yours in httpd.conf) and included it without path just Include user_rewrite.conf You have to discover it in your distro .) No, i'm writing DNS records by myself, and anyway it will create A record, it is suposed to be * CNAME example.com you also dont need 72.148.231.196 www ( * CNAME example.com is taking care of www) My DNS looks like this: A Record IP-Adresse Hostname (empty, A record for example.com is allready created, see bind records in /var/named/chroot/var/named) CNAME Hostname Target * example.com mail mail.myhosting.cz MX Mailserver Hostname 10 mail.myhosting.cz 20 mailbackup.myhosting.cz
help! how could i do this if webmail is in /home/admispconfig/ispconfig/web/roundcubemail/ It is outside of the document root. Using Mod_Rewrite seems to break roundcube & it wont login? & mail.anydomain.tld is not working for me? I used the ispconfig update function to install roundcube, and it defaults to https://anydomain.tld:81/roundcubemail/index.php I would like mail.anydomain.tld to use http on port 80 not https @ port 81, I've currently in user_rewrite.conf: (user.anydomain.tld redirection does work fine). I would like to be able to login @ both mail.anydomain.com && https://anydomain.tld:81/roundcubemail/index.php perhaps there is a way to do something like this with user_rewrite.conf to forward 80 to 81@https for both security and client convienence also? Ive seen mod_rewrite and simmiliar forward port.
mod_rewrite gives me a headache ;o/ Update: Took a crash course in mod_rewrite & got the url mask working, As a side note, if you are using ispconfig with global php disabled you will need to do the following (i don't know how elegant or secure this is) to get the roundcube login to show up @ mail.anydomain.tld <Directory /home/admispconfig/ispconfig/web/roundcubemail/> php_admin_value open_basedir none </Directory> however now that mail.anydomain.tld functions to serve the roundcube mail login page through Leo's rewrite conditions, I can not login through roundcube @ mail.anydomain.tld, I get a 404, roundcube log shows... ??????? UPDATE: Works fine!!!! sorry , there was a rogue .httaccess file in */roundcube! silly me.
hello I am using this mod on some accounts and I have a question: http://user.domain.tld (third level domain) works fine, but how can I configure it to be also working for http://www.user.domain.tld ? any help would be greatly appreciated! many thx!
Fairly certain this is not possible, you can attempt to alter the rewrite rules to pull this off but that would require you to treat & parse every instance of www. as a level 2 subdomain which would essentially bust www.domain.tld and fix www.user.domain.tld. However, creating a new site with its own DNS records for each user.domain.tld with a *.user.domain.tld co-domain(sub) should allow this. (unfortunetally thats the only way I can think to accomplish this). If you manage to figure out a more elegant solution please let me know! Best of luck, Gary Maurizi.