mod_rewrite with htaccess

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

mod_rewrite with htaccess

Post by jwalsh »

Hi,

I'm trying mod_rewrite for the first time, and I'm having a problem. The following doesn't do anything, but give me a blank page (no 404 or anything).


.htaccess

Code: Select all

LoadModule rewrite_module /usr/lib/apache/mod_rewrite.so
AddModule mod_rewrite.c

RewriteEngine on
RewriteRule /products/([0-9]+)/([0-9]+) /products.php?cat=$1&product=$2
Also, another one of my programmers has added this line to the top of the htaccess file, could this be conflicting?

Code: Select all

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
Thanks,

Josh
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mod_rewrite = regex.. Moved.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I don't think you can

Code: Select all

LoadModule rewrite_module /usr/lib/apache/mod_rewrite.so
AddModule mod_rewrite.c
in .htaccess, correct me if I'm wrong.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Apache module mod_so wrote:Syntax: LoadModule module filename
Context: server config
Status: Base
Module: mod_so
Apache Core Features wrote:Syntax: AddModule module [module] ...
Context: server config
Status: core
Compatibility: AddModule is only available in Apache 1.2 and later
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

I'm still stumped, I can't seem to get mod_rewrite to do anything.

Do I need an apache reboot even with an htaccess file? Been at this for hours, I'd really like to figure this out.

Josh
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post by jwalsh »

Ok,

I've been playing with this a little while, and have confirmed that mod_rewrite is on. Just to test, I've created a simple .htaccess file with the following in it..

Code: Select all

RewriteEngine On
RewriteBase /
RewriteRule ^/test/([0-9]+)$ /test.php?id=$1
This just generates a 404 error, because /test/333 doesn't exist, it's not rewriting. I've been playing with this for around a week, and no luck at all yet.

I heard a rumor that this doesn't work if I'm using the CGI version of PHP, but I don't know if I'm running on that or not.

I appreciate any help.

Josh
Post Reply