[SOLVED] Grrr! Can't even get started with mod_rewrite!

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

[SOLVED] Grrr! Can't even get started with mod_rewrite!

Post by Skittlewidth »

Just spent an hour browsing through the plentiful posts here on mod_rewrite, googled for tutorials, read some of the Apache manual, but still no joy.

I want to do some mod_rewrite testing on my local machine running Apache 1.3 and windows.
I've gone into the httpd.conf, uncommented the LoadModule rewrite_module modules/mod_rewrite.so line and the AddModule mod_rewrite.c line, rebooted Apache, even rebooted my machine and it still doesn't appear to have loaded, as the following simple code in an .htaccess file is not working.

Code: Select all

RewriteEngine On
RewriteRule ^test1.html$ test2.html [R=301]
I've tried it on the root, I've tried it in a sub folder, and it always shows the text on test1.html, so I'm guessing mod_rewrite isn't running. Any ideas why? I've had a look through my phpinfo and find no reference to it there either, but not sure which section it appears in. :evil:
Last edited by Skittlewidth on Tue Mar 14, 2006 3:19 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

RewriteEngine On
RewriteRule ^/test1.html$ test2.html [R=301]
:?:
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

Nope, didn't work. I ran one of my test files on a web server and it did what I expected so I know the .htaccess file was correct. Mod_rewrite is definately not loading. It's not appearing in the phpinfo and I've checked for possible duplication of the httpd.conf file.

The file mod_rewrite.so is in the modules directory as expected. I can't find mod_rewrite.c anywhere but then I can't find any other "files.c" either.

Do you think its worth me upgrading to Apache 2 and seeing if I can get it to work with that? I thought this was meant to be the simple bit!

EDIT: It was the allowoveride settings in the conf file and a browser caching problem that was playing up. I'm surprised none of the tutorials I saw mentioned changing the allowoveride settings, as of course it won't work otherwise.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

The windows version of .so files are .dll files... Thus you need to load a mod_rewrite.dll...

And it won't show up in your phpinfo page because it's apache related and not php...
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

Post by Skittlewidth »

Ah, ok, I was just following advice from this tutorial at
http://www.workingwith.me.uk/articles/s ... od_rewrite

For the purpose of this article, I’m going to assume that you don’t have access to view or edit the Apache server httpd.conf file, so the easiest way to check whether the mod_rewrite module is installed will be to look on your phpinfo page. If you’ve not already created one of these for yourself, just copy and paste the following code into an new text file using your favourite text editor, save it as phpinfo.php, and upload it to your server:

<?php phpinfo(); ?>Load that page up in your web browser, and perform a search for “mod_rewrite”. All being well, you’ll find it in the “Apache loaded modules” section of the page.
It is working now anyway, and as you say, it doesn't show up in phpinfo();
Post Reply