SharkBait Posted December 20, 2006 Share Posted December 20, 2006 Hi, I need some suggestions on how I should go about my next little ask.My blog script needs some form of Archives (like you see in WordPress etc).Now I am not sure how they are done but when you see the URL like this:www.mysite.com/2006/12/ - You would assume its year 2006 with month 12 correct?Now would something like this be helpful?[code]RewriteRule ^([0-9+)/([0-9+)$ archives.php?y=$1&m=$2[/code]Then I assume I would pull y and m from the URL with $_GET[] correct and then just continue on with that?Does this make sense in the way that perhaps Wordpress would do it? I am going about this the correct way right?Thanks! Quote Link to comment Share on other sites More sharing options...
steelmanronald06 Posted December 20, 2006 Share Posted December 20, 2006 http://www.onlamp.com/pub/a/php/2005/11/03/mvc_controller.html?page=2that has some great mod rewrite stuff on it. Quote Link to comment Share on other sites More sharing options...
Eric_Ryk Posted December 20, 2006 Share Posted December 20, 2006 I find that when you have things like that and the input in the URI can get varied with the amount of information and other possible confusing things that it's easier to let PHP handle the extra information because it is a full programming language. So what you do is have the URL take in one argument and you have mod_rewrite take anything extra in the URI and send it to that argument. Then using something simple like explode(ing) by a slash and sorting out the data from there. That way when you have too many arguments or too few the mod_rewrite doesn't go to a 404 when it can be handled more appropriately by PHP. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 20, 2006 Author Share Posted December 20, 2006 So what you're saying is that I should take the URL and explode() it on the slashes to see where it is?I would still need mod_rewrite though wouldn't I because I currently don't want to actually put my files 2 directories deep in the site. Quote Link to comment Share on other sites More sharing options...
Jenk Posted December 20, 2006 Share Posted December 20, 2006 [code]RewriteRule ^archive/([0-9]+)/([0-9]+)$ archives.php?y=$1&m=$2[/code]then you can use http://www.site.com/archive/2006/12 to get the archived article from dec 2006. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 20, 2006 Author Share Posted December 20, 2006 Alirght did that and it works.Thanks! Quote Link to comment Share on other sites More sharing options...
Jenk Posted December 20, 2006 Share Posted December 20, 2006 FYI, the difference between mine and yours, other than the use of archive, it I added the closing brackets to the [0-9] segments :) Quote Link to comment Share on other sites More sharing options...
SharkBait Posted December 20, 2006 Author Share Posted December 20, 2006 Yea I figured that was why mine wasnt working ;) Thanks agian! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.