Hello. I have broken my mind to try to solve a problem that should be very simple, but it is not working.
My site is navigated as follows in htaccess localhost/ProjetoBusca/index.php?pg=anuncio
being replaced with localhost/ProjetoBusca/anuncio
. So far it works perfectly. The problem is that I need a secondary GET, where the ideal would be to transform localhost/ProjetoBusca/index.php?pg=anuncio&n=354
being replaced with localhost/ProjetoBusca/anuncio/354
For this, in my htaccess I developed:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(.*)$ index.php?pg=$1&n=$2 [NC]
RewriteRule ^(.*)\/(.*)/$ index.php?pg=$1&n=$2 [NC]
When I work with / ad on the site (as quoted above) everything works fine, the problem is that when I call / ad / 354 I get the get of the n variable, but the full page CSS does not load. What could be happening?
Follow the index.php code:
<html>
<head>
<?php include("view/header.php"); ?>
</head>
<body>
<?php
include("view/topbar.php");
include("view/navbar.php");
if(isset($_GET['pg'])){
$url = $_GET['pg'];
if(!file_exists("$url.php")){
include("home.php");
}else{
include("$url.php");
}
}else{
include("home.php");
}
if(isset($_GET["n"])){
echo "foi instanciado n: ".$_GET["n"]; //para fins de teste
}
include("view/rodape.php");
include("view/copyright.php");
include("view/scripts.php");?>
</body>
</html>
Could anyone help me?
NOTE: include with view / ... is because they are in another same folder.