PDA

View Full Version : mod_rewrite in iVhosts_ispconfig.conf get overwritten with change to domain...


joshenry
14th February 2007, 23:00
Hey, I've been trying to find a place where I can put a rewrite to go from http://*.mydomain.com/webmail -> https://www.mydomain.com/webmail.

I've got it working however if I ever make a change to the domain it will over write the Vhosts_istpconfig.conf file and then it won't work anymore. Is there another place where apache will find the rewrite and process it properly? I've tried in the httpd.conf file, as well as .htaccess file with no go.

Thanks for any assistance.

Dy0nisus
15th February 2007, 00:48
Hi!

Everytime you make a change to a Web, ISPConfig rewrites the vhost - file of Apache.

You have to implement your rewrite - rule in the config file that is responsible for creating the config file ...

edit:

/root/ispconfig/scripts/lib/config.lib.php

joshenry
15th February 2007, 00:51
Gah... :-/ don't know where I need to add the information in that file. Am I able to add it in a different place in httpd.conf or anything like that?

martinfst
15th February 2007, 09:29
Am I able to add it in a different place in httpd.conf or anything like that?Rewrite rules also work in .htaccess files, which you can put in your web directory, These won't be overridden.

till
15th February 2007, 10:35
The correct solution is either to add the rwrite rule in a .htaccess file as martinfst pointed out or to add it in the apache directives field of the website in ISPConfig. The content of the apache directives field is inserted in the vhost by ISPConfig.

Vhosts_istpconfig.conf shall never be dited manually and editing the config.lib.php is also not recommended beacuse you will loose all cahnges when you update ISPConfig.

joshenry
15th February 2007, 17:19
Excellent, I'll give that a try.
Thanks again for your help.

joshenry
15th February 2007, 19:34
I can't seem to get the .htaccess file to see the rewrite rules. If I put a redirect in there that will work to a point but isn't going to do what I want it to do. Here is what I'm trying to do.

If someone accesses:
http://webmail.mydomain.com
https://webmail.mydomain.com
http://*.mydomain.com/webmail
https://*(other then www).mydomain.com/webmail

I need it to go to:
https://www.mydomain.com/webmail

I think I have the rule right:
RewriteEngine On
RewriteCond %{HTTP_HOST} webmail.mydomain.com$ [NC]
RewriteRule ^/(.*)$ https://webmail.mydomain.com/$1 [R,L]
RewriteRule ^/webmail/(.*)$ https://webmail.mydomain.com/$1 [R,L]

I've seen people writing rewrite rules in <IfModule mod_rewrite.c></IfModule> tags, I've tried with and without either way the site will not access any rewrite command I put in there.

Thanks again for any help.

falko
16th February 2007, 18:51
Please try to use AllowOverride All in your main Apache configuration, as shown here: http://www.howtoforge.com/forums/showpost.php?p=48399&postcount=2

joshenry
16th February 2007, 18:57
Yup, checked that and changed it so the web dir has AllowOverride All applied to it.
Commands in the .htaccess in the /web dir work just not the rewrite command. I tried a redirect and it works but I need a rewrite cause the redirect doesn't do what I want it to.

Thanks again.

falko
16th February 2007, 19:08
Maybe this page helps you: http://www.stevenhargrove.com/redirect-web-pages/