homepage Welcome to WebmasterWorld Guest from 184.73.40.21
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Mod rewrite question
Handling tokens in url?
jchance

10+ Year Member



 
Msg#: 3101844 posted 1:26 pm on Sep 29, 2006 (gmt 0)

I have a question on if and how I can do the following rewrite.

Lets say the user enters:
"testhtml_pk-32_jg-55_psd-92.html"

And I want to redirect it to:
"display_page.php?pn=testhtml&pl=32&jg=55&psd=92"

So basically I want to tokenize on "_" and then split each token by the "-" and then create query string parms out of the elements.

I want to make it handle X number of tokens, so it should also be able to handle:
"testhtml_pk-32_jg-55_psd-92_abc-123.html"
"testhtml_pk-32_jg-55_psd-92_abc-123_xyz-987.html"
etc...

How can I do this?

 

lmo4103

5+ Year Member



 
Msg#: 3101844 posted 2:55 pm on Sep 29, 2006 (gmt 0)

I have url done like
display_page.php/testhtml/pk-32/jg-55/psd-92.html

Then split up $_SERVER['PATH_INFO'] on the slashes to get the pieces.

If you do that, there is no mod_rewrite needed.

At least with my setup, it knows display_page.php is a php program and /testhtml/pk-32/jg-55/psd-92.html is a PATH_INFO.

( note: $_SERVER['PATH_INFO'] still had not been documented )

jchance

10+ Year Member



 
Msg#: 3101844 posted 6:50 pm on Sep 29, 2006 (gmt 0)

Well, I guess I could do something similar to that, but I really prefer to use mod rewrite so that all of my query parms show up in the php $_REQUEST object.

Anyone know how I can do this with mod_rewrite?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3101844 posted 7:05 pm on Sep 29, 2006 (gmt 0)

This thread [webmasterworld.com], in the Apache forum section of the WebmasterWorld library [webmasterworld.com], may prove helpful to you.

Also, see the references in our forum charter [webmasterworld.com].

Jim

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved