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

Apache Web Server Forum

    
Mod Rewrite
Multiple directories into a query : is this possible?
panic




msg:1510149
 11:01 pm on Jul 28, 2003 (gmt 0)

Essentially, what I'm trying to do is pass all subdirectories from a requested URL into a query string using Mod Rewrite.

For example :

[example.com...]

I'd like to pass everything after /widgets/ into a query string using Mod ReWrite.

Any ideas as to how this can be done?

-panic

 

claus




msg:1510150
 11:58 pm on Jul 28, 2003 (gmt 0)

Hi panic, i think your question is answered in this thread:

[webmasterworld.com...]

Here, Alternative_Future is asking for a way to go from 1 to 2 like this:

1) [mydomain.com...]
2) [mydomain.com?country=scotland&type=tour&area=grampian&town=buckie...]

Part of the answer involves PHP scripting, but there's also an option suggested that involves "RewriteMap" in stead. Check it out, i hope it helps.

/claus

Storyteller




msg:1510151
 1:41 am on Jul 29, 2003 (gmt 0)

Here's a script I wrote for a client that does similar thing. Once you get the idea, you can easily tailor it to your needs. The script transforms URLs of form:

example.com/cgi-bin/retrive/param1/value1/param2/value2/
into:
example.com/cgi-bin/retrive.cgi?param1=value1&param2=value2

If you aren't using ScriptAlias'ed cgi script as a destination, take the the [PT] flag out. So, here it goes:

RewriteRule (.*/retrieve[^&]*)/([^/]+)/([^/&]+)(.*) $1&$2=$3$4 [N]
RewriteRule (.*/)retrieve&([^/]*) $1retrieve.cgi?$2 [PT]

panic




msg:1510152
 5:02 am on Jul 29, 2003 (gmt 0)

I finally figured out how to use an unlimited amount of subdirectories and stick it into a query string.

Here's what I've got in my .htaccess :

RewriteEngine on
RewriteRule ^(.*)/$ output.php?querystring=$1 [L]

Then, in output.php, I split $querystring by "/", then I do my queries/manipulation/etc.

Thanks for everyone's help!

-panic

amoore




msg:1510153
 5:07 am on Jul 29, 2003 (gmt 0)

If you don't want the performance hit or complication of using mod_rewrite, you can look into the PATH_INFO environment variable.

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