View Single Post
Old 13th February 2007, 09:47
sfrank sfrank is offline
Junior Member
Join Date: May 2006
Posts: 22
Thanks: 0
Thanked 4 Times in 1 Post
Default Co/sub-domains without rewritten URLs

I've recently overcome a much debated situation, I needed subdomain support without URL rewriting.

For this example let's assume the site's primary domain is domain.tld and we'd like to create test.domain.tld with totally separate content.

The standard ISPConfig way of sub-domain creation is as follows:
- Add a new co-domain
- Hit the Forward option and put a folder's name in there
- Create the folder in the webroot

With this setup, if you visit http://test.domain.tld you'll get served with the content of the desired folder, though the mod_rewrite operation takes place in a manner not hidden from the user so thus the address in the URL bar of the browser immediately switches to http://domain.tld/test to show the real path the content is coming from.

This sometimes is not desirable, so I needed a "fix".
Here it is:
In /root/ispconfig/scripts/lib/config.lib.php at line 1368 remove the text [R].

Explanation: The R flag tells mod_rewrite that when it applied the rewrite rule on the URL it shall not feed it to Apache "URL to file parsing" mechanism internally, but start a whole new request by rewriting the address in the user's browser and reloading it.

Hope it helps some who wants to achieve the same behavior.

I've got confirmation from Till that this modification does not break any part of the code, but you need to note that this solution is not upgrade persistent. This means that any time you upgrade ISPConfig this file might get overwritten.

Furthermore as so many people would like to see this function added to ISPConfig, it'd be nice to somehow implement this one leaving the existing feature intact.

A "Do you want rewritten URLs" checkbox on the Forward tab maybe?
Reply With Quote
Sponsored Links