Apache Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationApache Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 12th, 2001, 07:07 AM
pippo's Avatar
pippo pippo is offline
A PAtCHy sErver
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Location: Italy
Posts: 410 pippo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
RewriteRule: "using more than one path"

Hard to explain in the subject what I need.

I have these rules inside my httpd.conf:

RewriteRule ^/articles/([0-9]+)/(en|it).htm$ /src/articles.php?lang=$2&id=$1 [T=application/x-httpd-php,L]
RewriteRule ^/articles/(en|it).htm$ /src/articles.php?lang=$2 [T=application/x-httpd-php,L]

The first is used to convert:
/articles/11/it.htm -->> /src/articles.php?lang=it&id=11

the second is used to convert:
/articles/it.htm -->> /src/articles.php?lang=it

I use articles.php to view the article if $id is not empty,
to display the list of articles if $id is empty.

I'm asking if there is a way with regular expression to put these two rules inside one.
I tried something like this:

^/articles/(([0-9]+)/(en|it).htm)|((en|it).htm)$

but with an orrible output.

Is it possible or is it better to have two rules as I wrote?

Reply With Quote
  #2  
Old November 12th, 2001, 01:35 PM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just don't use ([0-9]+), use ([0-9]*) instead, so that id can be empty.
You also should add a catch-all RewriteRule to display error message when it matches something under ^/articles(.*) but not your preceding Rule so that Apache knows what to do instead of throwing you with weird errors.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationApache Development > RewriteRule: "using more than one path"


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 2 hosted by Hostway
Stay green...Green IT