Forum Moderators: coopster

Message Too Old, No Replies

Dynamic folder creation?

         

pulszar

6:39 pm on Nov 9, 2006 (gmt 0)

10+ Year Member



You know how when you see an article from a site and the address looks something like:

[yoursitename.com...]

Is this folder "/2006/11/08/title.of.the.article.headline/" created dynamically? Or does someone create each individual folder that reflects the headline for each new page?

Would you use a template page titled index.php and just set the ID of the article that it corresponds to in the database, then create the folder manually and copy the index file over? If the page itself was dynamically created it would look something like index.php?id=302&title=title_of_the_article_headline, right? But from what I've read, it seems the long folder name helps with SEO

I'm in the process of creating my first dynamic website with MySQL and PHP and so far it's going well but I'm not sure about this part.

Thanks in advance for any suggestions.

eelixduppy

6:43 am on Nov 10, 2006 (gmt 0)



This can be accomplished using Apache's Mod Rewrite [httpd.apache.org]. You can get more detailed help on this topic in our Apache Forum [webmasterworld.com].

Aside from this, there are many resources available for people learning PHP. Here's a thread on Learning PHP - Books, Tutorials and Online Resources [webmasterworld.com]. Hope you find this useful! ;)

Best of luck!

pulszar

4:49 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



Thanks for the info. I read a ton of MOD_REWRITE info from you link and on devshed. I get the idea of how that works, but I'm not sure its what I need, and if it is, I'm not fully sure how blog software incorporates it.

For example, WordPress uses the [yousite.com...]

According to MOD_REWRITE, you need to enable it in your htaccess file (although it might already be turned on in your httpconf file for shared hosting) but if its not, wordpress links wouldn't work, right?

So my question is, do they use another method to format the link like that? For my site, I have a basic database with a few tables. On the main page and a few sub pages, there are post/blog like articles/news/reviews put up that show part of the article called from the database. I want to incorporate a link to the full story (something like permlink) without all the query info in the url (I assume the link output from the database in the actual webpage needs to be format with all the query info) but is mod rewrite is the only way to do this?

eelixduppy

5:00 pm on Nov 10, 2006 (gmt 0)



I'm not sure about WordPress.

>>but is mod rewrite is the only way to do this?

For your case it seems like mod_rewrite is the best way to do this. It's very simple once you understand how it works.

Related thread:

Hope this answers some of your questions. :)

pulszar

6:31 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



Thanks again eelix, there was some very helpful info in there. Although in the first link, in the first part of the post, it specifically says that Mod_Rewrite "does not make friendly URLS". There may be some technical difference in terms of what I said I was trying to do and what "friendly URLs" implies, and maybe I am just mixing up the terms, but to me it seems friendly URLs IS what I want. Either way, it looks like Mod_Rewrite is a good possibility.

In the process of looking around though, I found this article:

[evolt.org...]

It, too, requires htaccess access, but it uses PHP's explode() and Apache's FileMatch functions to work. It looks exactly like what I'm trying to do, and the author's example is almost a perfect example (incorporating the date and article title that is to be transformed into a URL).

I don't know how much better this method is over Mod_Rewrite, but they both look very effective. Eyeballing both methods, the explode() version looks easier to implement - though that doesn't necessarily mean better.

I will tool around with it and figure it out. Once I get it working I will drop some thoughts back here.

Jordo needs a drink

8:15 pm on Nov 10, 2006 (gmt 0)

10+ Year Member



Wordpress does have it built in, but you have to enable it. It's in the options and it also tells you how to modify the .htaccess. It's been a while, but I think the option is labled "search engine friendly url's" or something like that.