Forum Moderators: phranque

Message Too Old, No Replies

Installing Apache Rewrite Module on Win2k

Will the rewrite mod work on my home machine?

         

louponne

5:34 am on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



On one of my sites, I have installed a simple rewrite rule to serve .php pages as .htm

This works great on my web server, but *not* on my local testing machine, making it pretty hard to test my site locally! I'm on win2k, and have the latest release of apache. I found a couple of lines in //apache/conf/httpd.conf that mentioned the rewrite module and un-commented them.

Maybe the problem lies with my htaccess file? I have called it htaccess.txt on my local system and then renamed it in dos to .htaccess

But maybe that just won't work on win2k?

Air

6:21 am on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Should work fine on Win2K.

I think these are the two lines you need to uncomment in the httpd.conf file:

#LoadModule rewrite_module modules/mod_rewrite.so

...and

#AddModule mod_rewrite.c

Also this post [webmasterworld.com] may be of help.

louponne

8:49 am on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for your reply! I have read through all those threads, tried everything suggested and it still doesn't work.
Here's what I've done in my apache/conf/httpd.conf file

Following lines now uncommented:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

Inserted:
<Directory />
AllowOverride All
</Directory>

Modified:
AccessFileName htaccess.txt
(that way at least on my home machine, I don't have to go into dos and rename to .htacess every time I modify it)

And I have inserted, in my .htaccess, the line:
ErrorDocument 404 error.htm
and inserted a file called error.htm at the root of my site.

Well, that ErrorDocument line isn't working: if I try to access a non-existing file. So apache is definitely not "finding" and using that .htacess file.

(btw, I'm using Apache 1.3.24

help!

Air

3:21 pm on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well I am going to be of limited help, apache on Win systems is a combination that is mostly foreign to me. But since the underlying principles (and common problems) are the same on all systems, here's some things you've likely checked but here goes:

-Was the .htaccess file created with a plain text editor, if not some characters embedded in the file may keep it from working.

-Is the .htaccess file placed at the correct directory level to have the desired effect?

-this one's silly, but hey, we're covering all bases. Is the file you created spelled exactly the same as on AccessFileName?

These are pretty basic things but sometimes they're the gotcha things, anyway it will give you a couple more things to check until someone with Win/Apache experience comes along ...

Air

3:58 pm on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




Inserted:
<Directory />
AllowOverride All
</Directory>

From the grasping at straws department:

On a Unix type system "Directory /" would imply that the directive to allow .htaccess overrides applies to the entire file tree. I know forward slashes are used for paths with in the httpd.conf file even on windows, but should that be "<Directory c:/>"

louponne

4:31 pm on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again for the replies, but:

< Was the .htaccess file created with a plain text editor... etc >

This .htaccess file works perfectly on my remote server, so I'm positive that it is set up right.

- <Directory />
- AllowOverride All
- </Directory>
- From the grasping at straws department..

No, in my httpd.conf file (installed by the EasyPHP installation routine), there are other configurations using this construct, and everything else is working fine!

:(

ggrot

6:21 pm on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check the AccessFileName line in http.conf. It may be different under windows.

louponne

7:22 pm on Oct 12, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what you mean by "checking"?
As I said above, I modified that line as follows, to avoid having to go into dos to rename the file every time I made a change in it:

AccessFileName htaccess.txt

louponne

12:47 pm on Nov 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



HELP! This still isn't working on my system. :(

I have :

In httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
...
AddModule mod_rewrite.c
....
AllowOverride All

My .htaccess file is definitely being accessed, because if I put a line of garbage in it, I get the classic Internal Server Error.

The rewrite rule is good, because it's working on my webserver. I just can't get it to work on my home machine!

Just to be complete, here's the line I'm using, to rewrite any .htm file in the /wines/ directory to a .php extension:
rewriteRule ^wines/([0-9a-zA-Z]+).htm wines/$1.php [L]

Any ideas *anyone*?

andreasfriedrich

7:55 pm on Nov 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put

RewriteLog "F:/Apache Group/Apache/logs/rewrite.log" 
RewriteLogLevel 15

in your httpd.conf, restart apache and request the .htm files again. Look for error messages in your rewrite.log file. Post them if you do not understand them.

Andreas

louponne

10:19 pm on Nov 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ah, nobody ever suggested that before.

Now, I'm getting 5 lines in the rewrite.log file for every failed rewrite. After the initial part, which I assume is of no use for debuging, I'm getting (where full-path is the path on my own system, to the directory where the rewriting is supposed to be taking place:

strip per-dir prefix: c:/full_path/wines/bauser.htm -> wines/bauser.htm
applying pattern '^wines/([0-9a-zA-Z]+).htm' to uri 'wines/bauser.htm'
rewrite wines/bauser.htm -> wines/bauser.php
add per-dir prefix: wines/bauser.php -> c:/full_path/wines/bauser.php
add per-dir prefix: c:/full_path/wines/bauser.php -> c:/full_path/c:/full_path/wines/bauser.php

It looks to me that all's taking place correctly except that in the last line, it looks like it's adding back in the c:/full_path a second time?!

FWIW, I thought of mentioning two more things - 1. I'm accessing this directory via an alias that I've set up in easyphp. And 2. the .htaccess file is in the root directory of the site, one level up from the folder where the rewriting is supposed to be taking place.

andreasfriedrich

11:21 pm on Nov 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Iīve had that problem myself some time ago. I just donīt remember how I solved it. Iīll search through my notes and let you know if I find something.

Andreas

louponne

11:57 pm on Nov 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just found this:
[geocrawler.com...]
and this:
[groups.google.com...]

I don't know how to do the first, and tried the second.

I can't understand why more people haven't run into this problem?

louponne

12:02 am on Nov 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Iīll search through my notes and let you know if I find something.

Thanks - that would be great! :)

andreasfriedrich

12:24 am on Nov 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I havenīt found anything yet, but you might want to try adding the PT flag to your rewrite rule.

RewriteRule ^wines/([0-9a-zA-Z]+).htm wines/$1.php [L,PT]

If that does not help try this:

RewriteRule ^wines/([0-9a-zA-Z]+).htm ./wines/$1.php [L]

Those are just guesses, donīt know if it will help.

BTW, Iīve had this problem on a GNU/Linux system.

Andreas

louponne

7:46 am on Nov 17, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, tried your two suggestions, neither worked :(

Whatever I do, I'm still getting that second "add per-dir prefix:" line which doubles the path to the file.

ARG