LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-16-2007, 05:02 PM   #1
d_t_baker
Member
 
Registered: Oct 2003
Location: AU
Distribution: Ubuntu
Posts: 57

Rep: Reputation: 15
Unhappy Apache2 mod vhost_alias - problems with .htaccess mod rewrite


Hello all!

For those not familiar with mod vhost_alias it allows you to configure dynamic virtual hosts within apache.
For example loading http://test.localdev/ reads from the dynamic site /var/www/test , and loading http://FOOBAR.localdev/ will read from /var/www/FOOBAR

Heres is the configuration:
Code:
<VirtualHost *>
        ServerName localdev
        ServerAlias *.localdev

        VirtualDocumentRoot /var/www/%-2+/

        <Directory /var/www>
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/%-2+>
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>

        ErrorLog /var/log/apache2/error.log

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

</VirtualHost>
This works great and I can access any virtual site that has a directory entry in /var/www/.
However as soon as I throw a .htaccess with modrewrite into one of my dynamic virtual hosts I get some funky errors.

example .htaccess file in /var/www/test/:
Code:
RewriteEngine On
RewriteRule ^(.*)$ index.php
now when i load http://test.localdev/ I get 500 internal server error:
[HTML]<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator,
dtbaker@gmail.com and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.</p>
<p>More information about this error may be available
in the server error log.</p>
<hr>
<address>Apache/2.2.3 (Debian) PHP/5.2.0-10 Server at test.localdev Port 80</address>[/HTML]

this is what I get in the error.log:

Code:
[Fri Aug 17 08:13:22 2007] [error] [client 192.168.5.80] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Fri Aug 17 08:13:22 2007] [debug] core.c(3027): [client 192.168.5.80] r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /var/www/test/index.php
[Fri Aug 17 08:13:22 2007] [debug] core.c(3033): [client 192.168.5.80] redirected from r->uri = /
I have increased 'LimitInternalRecursion' and I get the same error.

This setup with .htaccess works correctly if I configure test.localdev as a normal apache vhost. However defeats the purpose of a single dynamic virtual hosts configuration.


Has anybody has success with dynamic virtual hosts and .htaccess rewrite?
Oh I have also tried placing the modrewrite rules directly into the apache configuration (no .htaccess) and its still the same.

Hope someone can help!

Kind Regards,
Dave
 
Old 08-16-2007, 07:32 PM   #2
d_t_baker
Member
 
Registered: Oct 2003
Location: AU
Distribution: Ubuntu
Posts: 57

Original Poster
Rep: Reputation: 15
Exclamation

Event weirder I get this in my error logs when I access http://test.localdev/pages/foo

Code:
[Fri Aug 17 10:13:15 2007] [error] [client 192.168.1.50] File does not exist: /var/www/test/var
this is with mod vhost_alias and the following .htaccess file in /var/www/test/:

Code:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/page.*$
RewriteRule ^(.*)$ /var/www/test/index.php
and I get a 404 result in the browser:

Code:
Not Found

The requested URL /var/www/test/index.php was not found on this server.
looking at http://test.localdev/ works and displays index.php correctly because the .htaccess rule does not match.

why would it be looking for /var/www/test/var ?? when I create the file /var/www/test/var and put some text in it, that text gets displayed when I load http://test.localdev/pages/foo O__o weird!!!


again here is the file in /etc/apache2/sites-enabled/dynamic_vhosts
I have tried this on two different apache2 installs and I get the same result both times.. what am i doing wrong ??

Code:
<VirtualHost *>
        ServerName localdev
        ServerAlias *.localdev

        VirtualDocumentRoot /var/www/%-2+/

        <Directory /var/www>
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/%-2+>
                Options Indexes FollowSymLinks
                AllowOverride All
        </Directory>


        ErrorLog /var/log/apache2/error.log

        LogLevel debug

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

</VirtualHost>
Any ideas?
 
  


Reply

Tags
apache2, modrewrite



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Easy Mod Rewrite LXer Syndicated Linux News 0 04-02-2007 11:16 PM
Mod REWRITE url rewriting gabsik Linux - Networking 1 09-29-2006 05:24 AM
Exception in mod-rewrite rule Boby Programming 0 01-17-2006 07:40 PM
Mod Rewrite Help carminejg3 Linux - Software 0 12-20-2004 05:19 PM
apache mod rewrite Robert0380 Linux - Software 5 07-31-2003 04:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration