Jump to content

Mod_rewrite along with Archive for a blog


SharkBait

Recommended Posts

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!

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.