mod_rewrite in per-server context

Problems with the Windows version of XAMPP, questions, comments, and anything related.

mod_rewrite in per-server context

Postby GetFree » 15. August 2007 05:56

On my local machine (Win32) I wanted to add a sub domain. so I put
this on the .htaccess of my document-root:

RewriteCond %{HTTP_HOST} ^subdomain\.
RewriteRule ^(.*)$ subdomain/$1

which worked fine. Every request to the subdomain is rewrited to the
directory "subdomain".

But now I want to do that in per-server context, inside a VirtualHost
directive, but it doesn't work.
I read the rewrite log and the directive never execute. It's like it
wasn't even there.

Any idea what the problem could be?

Thanks.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby Izzy » 15. August 2007 06:06

You only need create another virtual host container for the subdomain in the httpd-vhost.conf file.

Example:
You have a container set up for the main domain site.com
Make sure that works just fine.

Then create another container for subdomain.site.com just under the main container to keep it tidy.

This will of course point to the directory subdomain in the main domain directory of site.com.

Here is an example of what I mean:
Code: Select all
<VirtualHost *:80>
ServerName site.com
<Directory "C:/xampp/home/site" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "C:/xampp/home/site"
ScriptAlias /cgi-bin/ "C:/xampp/home/site/cgi-bin/"
ServerAdmin izzy@site.com
CustomLog domlogs/siteaccess.log combined
ErrorLog domlogs/siteerror.log
LogLevel error
</VirtualHost>

<VirtualHost *:80>
ServerName subdomain.site.com
<Directory "C:/xampp/home/site/subdomain" >
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "C:/xampp/home/site/subdomain"
ScriptAlias /cgi-bin/ "C:/xampp/home/site/subdomain/cgi-bin/"
ServerAdmin izzy@site.com
CustomLog domlogs/subdomainaccess.log combined
ErrorLog domlogs/subdomainerror.log
LogLevel error
</VirtualHost>

This method is useful because it gives you full control over the server's configuration of the subdomain just like you have over the main domain.

HTH

=================================================
Take a look at the new DeskTopXampp launch control posted by ridgewood:
http://community.apachefriends.org/f/viewtopi ... 967#103967

The DeskTopXampp launch control for XAMPP and XAMPPlite (DTX.exe)
is available here:
http://zedfiles.com/DTX/

I highly recommend DTX.
=================================================
Last edited by Izzy on 02. September 2007 04:28, edited 2 times in total.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby GetFree » 15. August 2007 18:50

That doesn't serve to my particular purpose.
mod_vhost_alias is not available for me either.

I need the subdomain to be just the same host as the main domain but with a special treatment.

I just want to know how can this be done inside a VirtualHost directive.

I tried this:
Code: Select all
<VirtualHost *:80>
        . . . .
        . . . .

        RewriteCond %{HTTP_HOST} ^subdomain\.
        RewriteRule ^(.*)$ subdomain/$1

</VirtualHost>

I get it to work using .htaccess files. And in the rewrite log I see the steps in the rewriting process.
But when I move the directives to the VirtualHost context, the rewrite log shows nothing about it (it doesn't even log that the rule doesn't match).
It's like apache doesn't see the rewriting directives in the VirtualHost.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55

Postby Wiedmann » 15. August 2007 19:17

I tried this:

I don't see a:
Code: Select all
RewriteEngine on


It's like apache doesn't see the rewriting directives in the VirtualHost.

Maybe the rewrite directives are in the wrong vhost.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby GetFree » 15. August 2007 21:25

Wiedmann wrote:I don't see a:
Code: Select all
RewriteEngine on

!@#$%!!!
How could I be so blind.

I'm gonna try it right now.
GetFree
 
Posts: 19
Joined: 18. October 2006 04:55


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests