Page 1 of 1
mod_rewrite
Posted: Tue Sep 20, 2005 11:38 pm
by s.dot
Man, I have played around with this thing for a couple of hours now. Apaches description seems much too complex for me to comprehend at the moment, and googling turns up specific tutorials that don't seem to match my needs. Could someone please show me how to do this:
turn
http://www.domain.com/page.php?var=something
into
http://www.domain.com/something
Posted: Wed Sep 21, 2005 12:25 am
by feyd
your sure you don't want the second to rewrite to the first?
Posted: Wed Sep 21, 2005 12:46 am
by s.dot
Yeah that's what I mean.
Posted: Wed Sep 21, 2005 6:16 am
by s.dot
my feeble attempt to write this myself goes as follows:
Code: Select all
ReWriteEngine on
ReWriteRule ^(\w+)(/)?$ showme.php?u=$1 [R]
Currently this doesn't do much. It gives me a page not found error.
What I'm attempting to match is any character A-Z a-z 0-9 underscores and hyphens (max 25 characters)
Posted: Wed Sep 21, 2005 7:14 am
by John Cartwright
Moved to Misc.
Posted: Thu Sep 22, 2005 2:33 am
by s.dot
OK. So I came up with this rule (despite my many attempts for help

). I guess once you're after something, eventually you'll find the answer.
Code: Select all
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)(/)?$ page.php?u=$1
This works great. Does anyone see any problems with it? Like would a normal page ever be caught by this regex?
Posted: Thu Sep 22, 2005 8:17 am
by feyd
test it, young lad. You're gettin' there jus' fine, me boy. A hearty yar to ya!
Posted: Fri Sep 30, 2005 9:51 am
by pilau
Maybe you could explain what was he trying to do?
Posted: Fri Sep 30, 2005 10:35 am
by feyd
pilau wrote:Maybe you could explain what was he trying to do?
explains it pretty well in his original post...
