Forum Moderators: phranque
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?
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.
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!
-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 ...
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:/>"
< 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!
:(
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*?
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.
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?
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