Go Back   SitePoint Forums > Forum Index > Host Your Site > Apache Configuration
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Nov 6, 2009, 06:33   #1
TomB
SitePoint Zealot
 
TomB's Avatar
 
Join Date: Oct 2005
Location: Milton Keynes, UK
Posts: 180
Odd mod_rewrite issue

Ok I'm confused.
I have about 20 virtualhosts set up on my development machine.

mod_rewrite works on a lot of them.

I've just tried to create a new one in the exact same way... mod_rewrite wont work.


My .htaccess has

Code:
RewriteEngine On
RewriteRule ^(.*)$ test.php
Doesn't work. Nothing happens.

If I change it to:

Code:
foo
RewriteEngine On
RewriteRule ^(.*)$ test.php
As expected I get an internal server error because it doesn't understand 'foo' so it's definatly reading the .htaccess file.

However...

If I change it to

Code:
RewriteEngine On
foo
RewriteRule ^(.*)$ test.php
it's as if the .htaccess isn't there.

Anything I put after RewriteEngine On is ignored. I've tried DirectoryIndex.


In the rewrite log I just get:
Code:
127.0.0.1 - - [06/Nov/2009:13:21:01 +0000] [dev.dev/sid#160f118][rid#1ece0b8/initial] (1) [perdir C:/www/dev/httpdocs/] pass through C:/www/dev/httpdocs/index2.php
And there's nothing in the apache error log. I just get

Code:
[Fri Nov 06 13:23:44 2009] [error] [client 127.0.0.1] script 'C:/www/dev/httpdocs/index2.php' not found or unable to stat
It's the same problem as before. Anything after RewriteEngine On is ignored.


Any ideas? I'm completley lost. I've tried copying a .htaccess file from a working vhost and that doesn't work either.


My vhost config looks like this:


Code:
<VirtualHost *:80>
    DocumentRoot "C:\www\ipa\httpdocs"
    ServerName ipa.dev
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "C:\www\dev\httpdocs"
    ServerName dev.dev
</VirtualHost>
The top virtual host, mod_rewrite works. The bottom one, doesnt.


Any ideas? I am thoroughly confused.
TomB is offline   Reply With Quote
Old Nov 6, 2009, 14:01   #2
dklynn
Hosting
SitePoint Award Recipient
 
dklynn's Avatar
 
Join Date: Feb 2002
Location: Auckland
Posts: 10,683
TB,

First, gudonya for setting up a development machine (test server) with VirtualHosts!

Second, learn some regex (start with the tutorial article linked in my signature)! Do you not think that test.php will match (.*)? In other words, loopy! mod_rewrite circles around through its own code until it can find no matches before it releases Apache to serve a file - unless it loops at which time it's supposed to just give up and quit (without taking the server down - which started with Apache 2.0). Consider yourself lucky!

foo: As you are aware, it's an "illegal" directive which is MEANT to cause a 500 response from the server. I have no idea why it didn't with your series of tests.

Regards,

DK
dklynn is offline   Reply With Quote
Old Nov 9, 2009, 03:35   #3
TomB
SitePoint Zealot
 
TomB's Avatar
 
Join Date: Oct 2005
Location: Milton Keynes, UK
Posts: 180
I wanted foo to cause a 500 error, to check the .htaccess was being parsed.


Anyway after a lot of trial and error I found the cause of the issue.


NotePad++ had the file mode set to mac (probably due to opening files from a collegue who's on a mac) so i'm not sure what combination of \r\n it used but changing it to unix file mode (\n) fixed the problem.

Odd, but glad I worked it out. Just a shame it took several hours of playing around!
TomB is offline   Reply With Quote
Old Nov 9, 2009, 14:25   #4
dklynn
Hosting
SitePoint Award Recipient
 
dklynn's Avatar
 
Join Date: Feb 2002
Location: Auckland
Posts: 10,683
TB,

Thanks for letting us know that all is okay (and the reason for the problem in the first place). Wouldn't it be nice if all three OS types would "converge?"

Regards,

DK
dklynn is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
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 On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 09:21.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved