Improving My Rule

Discuss practical ways rearrange URLs using mod_rewrite.

Improving My Rule

Postby david64 » Sat Jun 14, 2008 11:16 am

Hi. I have a rule that I need improving slightly:
Code: Select all
RewriteRule ^feed$ index.php?mode=XML&request=$0 [QSA,L]


To sum it up, when someone goes to domain.ext/feed, PHP gets told to go into XML mode. This works fine and dandy. However, I am having trouble getting extra info through in the URL.

For example, I might want to do domain.ext/feed/last-month. However, I don't know how to get this to work without also making PHP think it should go to XML mode when the url is domain.ext/feed/

Code: Select all
RewriteRule ^feed/(.+)$ index.php?mode=XML&request=$0 [QSA,L]


I could do the above, but I don't want the rule to work when feed is trailed with a slash (directory).
david64
 
Posts: 15
Joined: Wed Mar 26, 2008 2:16 pm

Postby david64 » Sat Jun 14, 2008 11:30 am

Code: Select all
RewriteRule ^feed\/(.+)|feed$ index.php?mode=XML&request=$0 [QSA,L]


is doing the trick. I don't know if anyone can recommend anything else.
david64
 
Posts: 15
Joined: Wed Mar 26, 2008 2:16 pm

Postby richardk » Sun Jun 15, 2008 10:50 am

I would use
Code: Select all
^feed(/.*)?$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 20 guests

cron