Jump to content

[SOLVED] A conceptual question about website and database


thankqwerty

Recommended Posts

Hi, i'm trying to make a website that i can post articles and stuff. I managed to store the articles in my database and displaying them .... etc, which are all fine. At the moment i'm using $GET and php to generate the page with the desired article. The link to any specific article would be something like http://localhost/database/display.php?num=6. Where the articles themselves has no real link. So my questions are:

 

1) how can i make it like the BBC for example, where every page has a link to a real file? (should i create a html file everytime when a new article is posted)

2) if i create a new html file for every new article, what should i store in those files? Since all the information are stored in the database already.

3) is there any downside for what i have at the moment?

Link to comment
Share on other sites

The mod_rewrite manual pages do come across as looking harder than it is. If you searched for tutorials on URL rewriting it all becomes a lot more straight forward. You will however need to be able to write (mostly basic) regular expressions. For instance, my previous example is as easy as the following...

#Assuming localhost/database is the webroot
RewriteRule ^display/([0-9]+)\.html$    display.php?num=$1

 

There are a number of advantages, here are a few:

  • Readability
  • Generally quicker to type
  • Easier to convey to people when talking over the phone, for example
  • Search engines used to like them a lot better when spidering - How relevant that is today, I don't know
  • It can add an extra layer of security, for example, in my example above, display.php is expecting nothing but an integer to come through in $_GET['num'], the regular expression ensures that - Though you'll need other rules to prevent passing anything to the original URL

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.