How to exchange content without changing the structure?

Asked

Viewed 146 times

0

I started making a website in the code anyway. Only this site will have several pages where on every page, the structure is the same, what changes is only the content. In order not to have to do the code page by page, do a lot of pages, I want to use a standard making structure include with php and picking up the contents on mysql.

Example:

https://www.youtube.com/watch?v= <- standard structure | define content -> Kplpa07kbr0

https://www.facebook.com/pg <- default structure | define content -> /zulaxcloud/

  • 1

    Usually to do this kind of thing one uses an MVC framework. As for example, the Laravel.

  • @Luizfelipe has some other option?

  • I don’t understand what the doubt is? You’re in trouble with us includes?

  • @Guilhermecostamilam actually wanted to make a structure just for various contents. For example: www.meuseite.com/pg1 - www.meuseite.com/pg2 - www.meuseite.com/pg3 .

  • And what’s the problem, what can’t you do? The only thing you need is an index with the layout and design, the queries and include

  • @Guilhermecostamilam I already have the default page, queries and includes. But as I will create a link to access a type of content using the default page?

Show 1 more comment

1 answer

1


If you already have everything ready, you can configure the file .htaccess to create a friendly url, as stackoverflow itself uses, a simple example:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^pagina/([0-9]+)/?$ /index.php?pagina=$1 [NC]
</IfModule>

This will make pages examplo.com/pagina/n, n being any integer number, be redirected to index.php, there you can take the page with the get and use to search the data in the database

<?php
    echo $_GET["pagina"];
?>

To better understand how to use the file .htaccess see that article

  • Just what I needed. Thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.