Web Server Configuration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsWeb DesignWeb Server Configuration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 9th, 2004, 08:54 PM
nuLime nuLime is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 7 nuLime User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 15 sec
Reputation Power: 0
Question Complex mod_rewrite dilemma

I have been searching for a solution to this for some time and have not found it on the web or these forums.

What I need to do is a tricky mod_rewrite that takes a dynamic length URL such as:
http://www.some-site.com/news_list/text_size~16/language~eng/organization~asc/May_News.html
...and then transforms it using mod_rewrite to the following:
http://www.some-site.com/news_list.php?text_size=16&language=eng&organization=asc

If the querystring was going to be fixed length, always having 3 parameters (text_size, language, organization) then an easy RewriteRule would solve the problem:
Code:
RewriteRule ^([a-z0-9_]+)~([a-z0-9_]+)\/([a-z0-9_]+)~([a-z0-9_]+)\/([a-z0-9_]+)~([a-z0-9_]+)\/([a-z0-9_]+)~([a-z0-9_]+)\/?[a-z0-9_]+\.html$ news_list.php?$1=$2&$3=$4&$5=$6 [NC]


However, what if the URL could contain any number of parameters to be rewritten? Instead of three, how about 30. This and the number of parameters may rarely be the same, only forming a typical pattern of "/var~val/var~val/".

With PHP the solution is simply to snip off the matched pattern, preg_replace() the original URL with the appropriate translations of "/" -> "&" and "~" to "=" and then put everything back together into the final URL.

How can this be done with mod_rewrite and still maintain the dynamic nature of a URL camouflaged to appear static??

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsWeb DesignWeb Server Configuration > Complex mod_rewrite dilemma


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT