Forum Moderators: phranque

Message Too Old, No Replies

Enabling Mod_rewrite Module Problem (windows)

everything set correctly, but doesn't work!

         

AnonyMouse

4:50 pm on Jul 31, 2004 (gmt 0)

10+ Year Member



Wondering if anyone can help me get to the bottom of this one....htaccess file works fine on remote host, but nada on localhost

Localhost is Windows2000, Apache 1.3.27 conf file has:

LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

<Directory "C:/Apache/Apache/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

.htaccess file has:

RewriteEngine on
RewriteCond %{REQUEST_URI}!\.(php¦txt¦jpe?g¦gif¦png¦css¦js¦inc)
RewriteRule (.*)$ /page.php?path=$1

From what I can see, my local machine is configured correctly, I am right? If so, why does the .htaccess file not work?

Comments appreciated, been banging my head against wall for two days now!

jdMorgan

5:47 pm on Jul 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First, try a simple rewrite:

RewriteRule ^silly\.html$ /exists.html [L]

Where "silly.html" is a page that does not exist, and "exists.html" is a simple, pure-html page that does exist. When you request silly.html, your server should return the contents of exists.html. This test minimizes dependencies on php and other complex factors.

Secondly, your <Directory> path seems complicated (should it contain "C:/Apache/Apache"?), and I don't see a <DocumentRoot> directive. If you are not using Multi-Views now, turn them off until actually needed -- content negotiation can cause a lot of side-issues.

Examining your error log can be helpful, too.

Jim

AnonyMouse

6:56 pm on Jul 31, 2004 (gmt 0)

10+ Year Member



Thanks for the reply, much appreciated. I tried your suggestions:

1. Added the simple RewriteRule and commented out the other:

RewriteCond %{REQUEST_URI}!\.(php¦txt¦jpe?g¦gif¦png¦css¦js¦inc)
#RewriteRule (.*)$ /page.php?path=$1
RewriteRule ^silly\.html$ /exists.html [L]

2. Turned off MultiViews
3. DocumentRoot "C:/Apache/Apache/htdocs" was/is in the httpd.conf (Repeated dir name as used to have Apache/Apache2 in there as well)

Unfortunately gave the same error 404 (and yes, "exists.html" exists!)

AnonyMouse

7:06 pm on Jul 31, 2004 (gmt 0)

10+ Year Member



Ferinfo, same config on a WinXP machine has the same non-result...

jdMorgan

2:11 am on Aug 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Unfortunately gave the same error 404 (and yes, "exists.html" exists!)

> > Examining your error log can be helpful, too.

Anything in there?

Jim

AnonyMouse

10:35 am on Aug 1, 2004 (gmt 0)

10+ Year Member



Aha...yes, and its a good clue:

"file does not exist: c:/apache/apache/htdocs/exists.html"

So the rewrite *is* kicking in, but it's not using the folder root (where the .htaccess file is) as it's starting point, it's using the server root.

So, I need to work out why it is not using the folder root...

AnonyMouse

10:46 am on Aug 1, 2004 (gmt 0)

10+ Year Member



Okay, nailed it!

Although this works on remote server:

RewriteRule (.*)$ /page.php?path=$1
#RewriteRule ^silly\.html$ /exists.html [L]

I need to drop the "/" for the redirect on the Windoze desktop:

RewriteRule (.*)$ page.php?path=$1
#RewriteRule ^silly\.html$ exists.html [L]

Don't know why that's the case, but it works. Thanks for your guidance!

(Interestingly, some relative urls are also showing up relative to server root, not folder root, so I guess there's a config missing somewhere?)

jdMorgan

6:46 pm on Aug 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to try defining <DocumentRoot> inside your virtual host container.
Alternately, you can try using RewriteBase in mod_rewrite.
These are guesses. :)

Jim

AnonyMouse

3:09 pm on Aug 7, 2004 (gmt 0)

10+ Year Member



Damn, I'm still having problems with this! I've got it working on my Windows2000 desktop, but my WindowsXP laptop won't run it.

This is the line from the .htacess file:
RewriteRule ^silly\.html$ exists.html [L]

If the file "exists.html" does *not* exist, the error in my log is:
File does not exist: c:/apache/apache/htdocs/bookabed/exists.html

Fair enough, the redirect is working, and cannot find the file. But this is the error I get when the file *does* exist:
Filename is not valid: c:/apache/apache/htdocs/bookabed/c

And the browser reads: Forbidden
You don't have permission to access /bookabed/c:/apache/apache/htdocs/bookabed/exists.html on this server.

What is going on here? If the file doesn't exist, the error is making sense - but if the file does exist, the error makes no sense at all!

Hitting the road tomorrow, really wanted to take a working site on my laptop with me, so help much apprecaited.

jdMorgan

6:34 pm on Aug 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This looks like one of those problems related to how and where directories are defined under Apache. I think your DocumentRoot directive (including c:/Apache/Apache) is wrong, but I can't tell remootely, and I'm no expert on it anyway. I suggest you look at some working Windows/Apache site set-up examples (do a search) and emulate those. The paths shown in the error log should help you get it working.

Jim

AnonyMouse

10:39 am on Aug 8, 2004 (gmt 0)

10+ Year Member



In case anyone passes by with the same 403 problem, here's the solution:

It seems it's the the RewriteCond %{REQUEST_FILENAME} -f that's the
problem - windows problems normally are to do with files...so comment out or remove lines like these:

#RewriteCond %{REQUEST_FILENAME} -f
#RewriteRule .+ %{REQUEST_FILENAME} [L]

Not quite the ideal solution, but mostly I think it'll work until someone works out how to check for existence of files on windoze XP!

jdMorgan

6:53 pm on Aug 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That code, standing alone, doesn't make sense anyway, so it may not really be a Windows problem. What was its purpose?

Jim