2
I need help with a question I’ve been having. The URL of blogs in general on the web are by directories for example: www.qualquercoisa/post/example-do-post.
I am creating a blog that is dynamic and use parameters in the URL to display the content on the page, example: www.qualquercoisa/post? id=1.
The database has a table called post
, example:
nome varchar | conteúdo: <h1>Meu primeiro post</h1>
conteudo varchar | conteúdo: <p>Este é o meu conteudo do primeiro post</p>
When the user clicks on the link, it goes to a file called post
and along with it the post ID to display. With the ID I can take the database name and content.
Doubt: Is it wrong to do it this way? Do regular blogs have to create a file with the post when they want to post a story? Creating a file for each post would not weigh on the server?
It would. The technique that is used and you should search is URL rewriting. You define a entry-point standard for your entire application and handles the accessed URL. A 1:1 relationship is usually defined between the URL and the post (in general, through the post title after the slugify)
– Woss
Thank you, I’ll look into.
– João Victor Nóbrega
Just one question: are you doing this "on the nail" on purpose? As it could easily do everything in Wordpress.
– Rogério Dec
@Rogériodec the site is about programming. If it were to use wordpress, nor would it make sense to ask here, after all in WP already has the feature ready. But of curiosity, why anyone would use WP nowadays with so much better stuff (made in hand, including).
– Bacco
@Rogériodec I’m doing it in the nail to understand how everything works. Before using any framework I want to understand what happens behind the curtains.
– João Victor Nóbrega
https://httpd.apache.org/docs/current/mod/mod_rewrite.html
– MagicHat
@Bacco, many years ago I developed sites in Drupal, because at the time Wordpress was basically a blog creator. But currently WP is very well advanced. But which CMS you say are far better than Wordpress?
– Rogério Dec
@Andersoncarloswoss I have to thank you again. What you said was what I needed. I have not fully solved my problem, but I have found a way. vlw man
– João Victor Nóbrega