Problems with creating friendly URLs

0

I researched a lot about friendly URLs. I've put some instructions to handle some pages - some static and some dynamic, however, still not working properly. Follow below:

The home page displays a listing of the posts saved to the database. The file is called index.php In this case, it includes the following line:

RewriteRule ^inicio$ index.php [NC,L]

In this way, the home page can be viewed from the url: www.site.com.br or www.site.com.br/inicio

A second detail: Because the home page can contain pagination, it then includes the following line:

RewriteRule ^inicio/(.*)$ index.php?pagina=$1 [NC,L]

In this way, it can also accept: www.site.com.br/1 , www.site.com.br/2 and etc.

And finally, for the display of each of the posts, I wrote the line as follows:

RewriteRule ^(.*)$ post.php?postagem=$1 [NC,L]

In this way, the post.php file would interpret the url and display its respective post. Example: www.site.com.br/me-primeiro-post .

In short: I'm considering that the site has only two files: index.php and post.php.

The problem is that I noticed that there are conflicts between the above instructions. This way, I can not access the pages correctly. Could you help me with how I can proceed? Is there any way I can also simplify / optimize the three lines above in order to preserve these three possibilities?

    
asked by anonymous 02.01.2019 / 19:13

0 answers