5
I have this tag on the index
<a href="projeto">Projeto</a>
Who sends me to this page
localhost/project.php
That I’m leaving like this
localhost/project
With the
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
DirectoryIndex home.php home.html index.php index.html
But now I need to pass two variables through the url, it would look like this
<a href="projeto?id=25&nome=aqui_vai_o_nome">Projeto</a>
But I need the URL to look like this
localhost/project/25/aqui_vai_o_name
Remembering that later I need to get these two data inside the page PROJECT
This is the code of the.php project
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Document</title>
<?php include('include/baseHead-2.php'); ?>
<!-- Bootstrap CSS -->
<?php include('include/fonts.php'); ?>
<?php include('include/css-2.php'); ?>
</head>
<body>
<?php include('include/topbar-2.php'); ?>
<div class="container-flex m-primary container-title-page">
<div class="container py-80">
<div><h1 class="ff-os">Titulo da pagina</h1></div>
<div><h2 class="ff-os"><a href="../../home" class="ff-os">Home</a> / Pagina atual</h2></div>
</div>
</div>
<div class="container py-100 container-*">
<div class="row h-200px">
<?php
echo $_GET['id'];
?>
</div>
</div>
<?php include('include/footer-2.php'); ?>
</body>
<?php include('include/js-2.php'); ?>
</html>
This is my . htaccess and the new.php project where you’re not getting $_GET
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([0-9A-z_-]+)$ $1.php
RewriteRule ^projeto\/([0-9A-z_-]+)\/([0-9A-z_-]+)$ projeto.php?id=$1&nome=$2
DirectoryIndex home.php home.html index.php index.html
project.php - "project/15/name"
<?php
echo $_GET['id']."</br>";
echo $_GET['nome'];
?>
Unfortunately, I can’t see what’s wrong. If you want I can create another answer with another type of structure for you to test.
– Andrei Coelho