Forum Topic: mod_rewrite

(120 views • 3 replies)

This topic is 1 page long.

<< < > >>
None

FireBred

Reply To Post Reply & Quote

Posted at: 1/15/09 08:57 AM

FireBred EVIL LEVEL 05

Sign-Up: 02/26/06

Posts: 149

Hello guys, just a quick one.

Need a bit of help with mod_rewrite.

I'm have a URL which looks like this:

http://www.example.com/mypage.php?firstV ar=abc&secondVar=229

and I was wondering if it was possible to rewrite it to look like:

http://www.example.com/abc/mypage.php?se condVar=229

Getting .com/abc/229 would be easy enough, but it's not exactly what I'm looking for. I'll use it if needs be, I'm just curious if there's a way of doing the above?

Thanks in advance guys.
Hope to see some of you Saturday?


None

WoogieNoogie

Reply To Post Reply & Quote

Posted at: 1/15/09 05:29 PM

WoogieNoogie LIGHT LEVEL 14

Sign-Up: 06/26/05

Posts: 3,284

RewriteRule /([a-z]+/mypage.php?secondVar=([0-9]+) /mypage.php?firstVar=$1&secondVar=$2

Not tested, and I'm a bit rusty, but that should work at first glance.


None

Sir-Davey

Reply To Post Reply & Quote

Posted at: 1/15/09 07:25 PM

Sir-Davey FAB LEVEL 19

Sign-Up: 07/09/01

Posts: 3,093

At 1/15/09 05:29 PM, WoogieNoogie wrote: RewriteRule /([a-z]+/mypage.php?secondVar=([0-9]+) /mypage.php?firstVar=$1&secondVar=$2

Not tested, and I'm a bit rusty, but that should work at first glance.

That would be

RewriteRule /([a-z]+)/mypage.php?(.+) /mypage.php?firstvar=$1&$2

which would allow more flexibility in what variables are accepted. Firstvar being hard-coded, the rest will allow anything

BBS Signature

None

FireBred

Reply To Post Reply & Quote

Posted at: 1/16/09 07:38 AM

FireBred EVIL LEVEL 05

Sign-Up: 02/26/06

Posts: 149

Brilliant, cheers guys. ^_^


All times are Eastern Standard Time (GMT -5) | Current Time: 01:31 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!