HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (
-   Tips/Tricks/Mods (
-   -   Co/sub-domains without rewritten URLs (

sfrank 13th February 2007 10:47

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?

frk0r 15th February 2007 03:26

i love you :P

galaxyboss 18th February 2007 02:39

is this effect all rewrite URL
HI sfrank,

is this modification will effect SEF modules such asin CMS(like joomla) and .htaccess if I want to use it?

sfrank 19th February 2007 10:53


Originally Posted by galaxyboss
HI sfrank,

is this modification will effect SEF modules such asin CMS(like joomla) and .htaccess if I want to use it?

I'm sorry but I've got no idea... All I cared was making sure no existing functionality in ISPConfig shall break. Maybe, if you could give me more details on what functionality you're fearing to get broken when you say .htaccess I might be able to answer it, but it's way to general like this.

thecaptainjs 19th February 2007 20:07

Wow, you rock! I was looking for this!

galaxyboss 19th February 2007 20:17

yes it working BUT
yes its working but after reading howtoforge, I get better idea
doing what till recommend:

what do you think?:rolleyes:

thecaptainjs 19th February 2007 20:48

The point of this is to keep it all under the same website.

Yea, creating a new website works fine, but not the way some of us want.

thecaptainjs 21st February 2007 16:26

I noticed a problem. Now this could be with my install, but I have a subdomain setup (using this trick).

There is an index.php there, and I get an internal server error unless I type in /index.php.

And no, I dont have this problem any other times.

falko 22nd February 2007 21:56

Maybe you must change a DirectoryIndex directive somewhere?

PierreR32 25th May 2007 08:54

Sorry i Have a question.

by the code

... "\nRewriteRule  ^/(.*)$  http://".$servername.$domain["domain_weiterleitung"]."$1  [R]";
Must i Remove ONLY the PART with [R] or the complete Line ?

Also this Part ?


$rewrite_rule .= "\nRewriteCond %{HTTP_HOST}  ^".$rewrite_cond_url." [NC]";
          if(substr($domain["domain_weiterleitung"],0,4) == "http" || substr($domain["domain_weiterleitung"],0,4) == "HTTP"){
            $domain["domain_weiterleitung"] = strtolower($domain["domain_weiterleitung"]);
            if(substr($domain["domain_weiterleitung"],-1) == "/") $domain["domain_weiterleitung"] = substr($domain["domain_weiterleitung"],0$
            $rewrite_rule .= "\nRewriteRule ^/(.*)        ".$domain["domain_weiterleitung"]."/$1 [L,R]";
          } else {
            //if(substr($domain["domain_weiterleitung"],-1) != "/") $domain["domain_weiterleitung"] .= "/";
            if(substr($domain["domain_weiterleitung"],0,1) != "/") $domain["domain_weiterleitung"] = "/".$domain["domain_weiterleitung"];
            $rewrite_rule .= "\nRewriteRule  ^/(.*)$  http://".$servername.$domain["domain_weiterleitung"]."$1  [R]";

Thx for Help.

Greetz Pierre

All times are GMT +2. The time now is 06:32.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.