Click to See Complete Forum and Search --> : mod_rewrite driving me insane!


Paul Jr
07-24-2004, 02:07 PM
ARGH! mod_rewrite will be the death of me, I tell you.

I looked at about the first six results of this Google search (http://www.google.com/search?q=mod_rewrite&sourceid=mozilla-search&start=0&start=0&ie=utf-8&oe=utf-8) and came up with the following as a test:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule /archive.php/(\d+)/(\d+)/(\d+) /archive.php?date=$1/$2/$3
</IfModule>

Guess what? Yup — it doesn’t work. I have tried many variations on that. I tried a simple redirect, and that worked, but I just can’t seem to get this working! :(

The basic idea is that someone types in http://www.url.com/archive.php/2004/06/16 and it’s the equivalent of them typing in http://www.url.com/archive.php?date=2004/06/16 It would be even better if I could get rid of the .php all together (http://www.url.com/archive/2004/06/16), but let’s not get ahead of ourselves.

I’m reading an article at Sitepoint, but nothing seems to be helping me.

Paul Jr
07-24-2004, 04:12 PM
I read some more, tested some more, swore some more, and figured something out.

Everything now is in an .htaccess file located in my document root. I figured out that, for some reason, I cannot rewrite the url of the page on which the rewrite is occuring. Above I was trying to rewrite archive.php?date=2004/06/16 to archive.php/2004/06/16 which I cannot do (I don’t know why), but I can do this:

RewriteRule test/archive/([0-9]+/[0-9]+/[0-9]+) /archive.php?date=$1

And now that I think about it, this will work perfectly (I think). So, I guess I fixed it myself. :D But if anyone has any good information on mod_rewrite (I see lots of confusing, different, and seemingly bad information all over), then please, post!

spufi
07-25-2004, 05:27 AM
http://www.sitepoint.com/article/guide-url-rewriting