php friendly URLs

0
Hello, my question is: I am developing a system in HTML and PHP, I have been researching on friendly URLs, some friends have told me to use it because according to them the main page would not be updated every time I access a link. Well, I've followed a lot of tutorials, done dozens of different ways I found on the web and I believe it's not working. To test I am using a function that does UPDATE in a mysql database at the top of the page, ie every time every page is updated it adds +1 by counting the return of the +1 bank. I would like to know how do I when I call another page in a link just search the content and do not refresh on every page

I followed this tutorial link

Follow the code I made:

.htaccess

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1

config.inc.php

<?php
define('HOME', 'http://localhost/testeAmigo/');
define('THEME','paginas');

define('INCLUDE_PATH', HOME.THEME);
define('REQUIRE_PATH',THEME);

$getUrl = strip_tags(trim(filter_input(INPUT_GET, 'url', FILTER_DEFAULT)));
$setUrl = (empty($getUrl) ? 'index' : $getUrl);
$Url = explode('/', $setUrl);
//var_dump($Url);
 ?>

index.php

<?php
require 'config.inc.php';
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Teste Urls Amigáveis</title>
</head>
<body>
  <header>
    <nav>
      <ul>
        <li><a href="?url=home"> Home</a></li>
        <li><a href="?url=contato"> Contato</a></li>
        <li><a href="?url=sobre"> Sobre</a></li>
      </ul>
    </nav>
  </header>
  <hr>

  <!--CONTEUDO -->
  <?php
  $Url [1] = (empty($Url[1]) ? null : $Url[1]);
  if(file_exists(REQUIRE_PATH . '/' . $Url[0] . '.php')):
    require REQUIRE_PATH . '/' . $Url[0] . '.php';
    elseif(file_exists(REQUIRE_PATH . '/' . $Url[0] . '/' . $Url[1] . '.php')):
      require REQUIRE_PATH . '/' . $Url[0] . '/' . $Url[1] . '.php';
    else:
      require REQUIRE_PATH . '/404.php';
    endif;
    ?>
    <!--CONTEUDO -->
    <hr>
    <footer>
      <center>
        <label>www.teste123.com</label>
      </center>

    </footer>
  </body>
  </html>

In addition there is the folder 'pagians' which contains the files home.php, contact, php and sobre.php.

    
asked by anonymous 15.03.2018 / 03:00

0 answers