Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite charity

         

paradoxos

7:42 pm on Jan 29, 2005 (gmt 0)

10+ Year Member



I'm trying to do a mod_rewrite for my church. I put this in:

RewriteEngine On
RewriteRule ^culture/(.*)/(.*) www.example.com/culture/article.php?content=$1&type=$2

and nothing happened.

What I'm trying to do is have

www.example.com/culture/article.php?content=other&type=HollowVows.html
become
www.example.com/culture/other/HollowVows.html
which is
www.example.com/culture/$2/$1

I've never done this so any help is appreciated.

jdMorgan

9:48 pm on Jan 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're close. I'd use:

RewriteEngine on
RewriteRule ^culture/([^/]+)/(.*)/?$ /culture/article.php?content=$1&type=$2 [L]

Having done that, you'll need to modify article.php (and any other such scripts) to output "friendly" URLs in links, so that these links will be seen and followed by your visitors and search engine spiders. When such a URL is is subsequently requested from your server, your mod_rewrite code above will convert it back into the form necessary to call aritcle.php with the proper parameters.

See the mod_rewrite and regular-expressions references cited in our forum charter.

Jim