Welcome to WebmasterWorld Guest from 54.196.176.3

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Apache and mod-rewrite on IIS

Need help getting mod_rewrite working!

     

dioman

10:06 pm on Mar 19, 2002 (gmt 0)

10+ Year Member



I am running Apache Server 1.3.12 on Win 2K.

I am unable to get mod-rewrite to run. Any ideas on set up, please?

The LoadModule rewrite_module modules/ApacheModuleRewrite.dll line of code seems to be present and the hash has been removed. However, if I run "apache -l" the module is not shown as present.

I seem to remember somewhere reading about needing to place an activate-module line somewhere.

Thankyou,

DaveAtIFG

11:15 pm on Mar 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld dioman! :) Unfortunately I can't answer your question, sorry. :( Apache's page about Apache under Windows [httpd.apache.org] suggests questions be posted to the comp.infosystems.www.servers.ms-windows newsgroup. If no one jumps in here with your answer, it's probably worth a try. Just be sure to drop back in and see us!

dioman

8:01 pm on Mar 21, 2002 (gmt 0)

10+ Year Member



DaveAtIFG,

Thanks for your reply. I'll keep looking.

PsychoTekk

8:53 pm on Mar 21, 2002 (gmt 0)

10+ Year Member



hi dioman, i'm not really sure whether i got the point, however, this
thread might help you:
[webmasterworld.com...]

i myself run an apache 1.3.20 on my win2000 machine.
the line in my httpd.conf file to load the module looks like this:
LoadModule rewrite_module modules/mod_rewrite.so

are you sure your apache uses dllibraries?

dioman

9:52 pm on Mar 21, 2002 (gmt 0)

10+ Year Member



Thanks PsychoTekk for your reply.

I've looked at the forum thread suggested and seem to think that I've got all the required lines of code in place.

For example:
LoadModule rewrite_module modules/mod_rewrite.so
AddModule mod_rewrite.c

I've upgraded to Apache 1.2.23 and notice that the .dll files are no longer there.

Things still do not seem to be working.

Any other ideas will be welcome.

gethan

10:40 pm on Mar 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome Dioman,

Do you get any errors in your log file?
What type of rules are you trying?

dioman

7:34 am on Mar 22, 2002 (gmt 0)

10+ Year Member



Gethan,

I have a .htaccess file called "my.htaccess" in a directory called "E:/apache/htdocs/re_write_test".

The line of code in the mt.htaccess is:

RewriteEngine on
RewriteRule ^news(.*)\.html$ shownews.php?id=$1.

The line of httpd.cof file identifying the my.htaccess file is:
AccessFileName my.htaccess

The error.log gives the following errors:
[Thu Mar 21 21:57:34 2002] [error] [client 127.0.0.1] File does not exist:
e:/apache/htdocs/re_write_test/news1.html

Also it gives this error on starting up the service:
[Thu Mar 21 22:08:35 2002] [error] [client 127.0.0.1] Premature end of script headers: e:/php4/php.exe.

Thank you for your help.

dioman

7:41 am on Mar 22, 2002 (gmt 0)

10+ Year Member



Gethan,

By the way, PHP is working despite the error message.

Thanks

gethan

1:31 pm on Mar 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry for the delay Dioman - had a weekend for a change ;)

Ok, no solutions - just suggestions.

Firstly, check that in httpd.conf that you allow overrides.

<Directory />
Options # as before
AllowOverride All
</Directory>

(if this is a live hosting server then not a good idea - but for a test server it's fine.)

Next test my.htaccess file is being used (possibly: invalid httpd.conf or that my.htaccess has a limited range of functions) - to test this put in

ErrorDocument 404 /error.html

And check that you get your error document displayed OK.

Alternatively try using .htaccess - with the same rules.

I hope this gets you closer to a working mod_rewrite.

dioman

5:55 pm on Mar 24, 2002 (gmt 0)

10+ Year Member



Gethan,

Thank you for your reply. I really appreciate your help.

I've tried your suggestions with some success. The purpose-made 404 ("error.html")file does not show when the note1.html file is called (you will recall that "note1.html" is supossed to resolve in calling "shownews.php?id=1"), which I suppose shows that it is not being read. However, I cannot create a file with no prefix (i.e. a file named ".htaccess") using notepad. Is this possible in windows?

Sorry to be such a pest>

Key_Master

6:06 pm on Mar 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dioman,

Write the file with notepad and name it htaccess.txt then use Windows Explorer to rename the file .htaccess

dioman

7:23 pm on Mar 24, 2002 (gmt 0)

10+ Year Member



Key_Master,

I've named the file "htaccess.txt" in Notepad and then tried to change it in Windows Explorer to ".htaccess". It keeps telling me that I can't due to the fact that "You must type a file name"(i.e. with a file prefix). Where am I going wrong?

Finally, I have changed the following "AllowOverride" expressions:

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

Alias /icons/ "E:/Apache/icons/"

<Directory "E:/Apache/icons">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

# "E:/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/Apache/cgi-bin">
AllowOverride All
Options None
Order allow,deny
Allow from all
</Directory>

Am I being thick? (Please be kind when answering that question.)

With thanks yet again.

Key_Master

7:58 pm on Mar 24, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I found a fix for that. I'm on XP so there might be some minor differences in the instructions.

In Windows Explorer click on:

Tools>>Folder Options...>>File Types>>New

It will ask for a file extension. Type in ".htaccess" then click "ok". You will be shown the details for ".htaccess". Click on "Change", select a program from a list (Notepad or some other text editor). Afterwords you should be able to save and edit .htaccess files with Notepad.

dioman

8:00 pm on Mar 24, 2002 (gmt 0)

10+ Year Member



Yes, me again.

I've just found something interesting. The ReWrite code in the htaccess file is:

"ErrorDocument 404 E:/apache/htdocs/error.html

RewriteEngine on
#RewriteBase /
RewriteRule ^news(.*)\.html$ shownews.php?id=$1"

The intention is that news1.html will be parsed as "shownews.php?id=1".

If I enter "shownews.php?id=1" into the browser the return field is as expected. However, If I input "news1.html", I get an Explorer 404 page: If I enter "snews.html", I get my "error.html" page as identified in the htaccess code. So the file seems to be being read.

Is it the ReWrite code?

gethan

3:28 pm on Mar 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We're getting close :)

RewriteEngine on
RewriteRule ^/news(.*)\.html$ /shownews.php?id=$1

Assuming your two files are in the web root folder.

Should do it.... let me know ;)

The rewritebase option is very useful in situations where your running under a couple of sub dirs ... eg. /dir1/dir2/news3.html

Is written more easily as

RewriteEngine on
RewriteBase /dir1/dir2
RewriteRule ^/news(.*)\.html$ shownews.php?id=$1

HTH

dioman

7:31 pm on Mar 25, 2002 (gmt 0)

10+ Year Member



Gethan,

Thank you once again for your patience.

I have altered my .htaccess file to your posted code as I found that you had placed an extra forward slash infront of the shownews.php statement.

Unfortunately, it still does not work. However, I continue to get the standard Microsoft 404 screen if I request "http://localhost/news1.html" and the error.log does not log an error. But if I request "http://localhost/news1.html" I get my purpose made "error.html" file and the error.log shows
"[Mon Mar 25 19:23:13 2002] [error] [client 127.0.0.1] File does not exist:e:/apache/htdocs/nejws1.html"

Something is happening but I cannot grasp what. Or where to start looking.

gethan

8:50 pm on Mar 25, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure whats happening here - it should have worked already.

Lets go back a stage and try a very simple rewrite rule

RewriteEngine on
RewriteRule ^/test\.html$ /works.html

Create only the file works.html - remove the errordocument and then request test.html - With that test we know that re_write is either working or not.

Guys - feel free to step in with the answer anytime :)

dioman

7:38 am on Mar 26, 2002 (gmt 0)

10+ Year Member



gethan,

I've tried your test without success, so I assume that mod_rewrite isn't working. I get a standard MS 404 file when test.html is requested.

The error log gives only:
[Tue Mar 26 07:16:03 2002] [error] Cannot remove module mod_php4.c: not found in module list
[Tue Mar 26 07:29:27 2002] [error] [client 127.0.0.1] File does not exist: e:/apache/htdocs/test.html.

Thank you for all your concern and help.

By the way, I like the Norfolk artists web site. I live in Cambridgeshire, only a stone's throw away from the North-West Norfolk coast.

dioman

11:23 am on Mar 29, 2002 (gmt 0)

10+ Year Member



The solution to the problem lies in the additional forward slash needed before the actual file declaration, as in before shownews.php:

RewriteRule ^news(.*)\.html$ /shownews.php?id=$1

Many thanks to all who have helped.