Reputation: 27
Hello guys I was wondering how blog articles work I mean they are stored in a database right? so how come when I go to an articles its like this:
www.something.com/seths_blog/2015/02/shoes-that-dont-fit-and-free-salt.html
for example I mean do they use php create and create these blogs on files on there htaccess or there is a way to do it efficiently I mean they got to put in it in a Database because sorting comments and so are much more efficient rating and such or polls are well really need the answer thank you
Upvotes: 0
Views: 26
Reputation: 467
Edit your .htaccess
file to add this:
#forward all traffic to index to be handled there except resources
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.js|\.css)$
RewriteRule (.*) index.php [QSA]
Note that any other file types you don't want to be forwarded will need to be added to the list of file types above. What this line is doing is forwarding all file requests to your index.php
file except the ones you declare (like images).
Next, go to your index.php
file and add this code:
echo "My URL is:" . $_SERVER['REQUEST_URI'];
This is the basic answer. Now, any question you have beyond this is a matter of basic PHP (and probably MySQL). You can manipulate that data in a limitless combination of ways.
Upvotes: 2