0
Hello. I have been breaking my head too much to try to solve a problem that should be very simple but is not working.
My website is browsed as follows on htaccess localhost/ProjetoBusca/index.php?pg=anuncio
being replaced by 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 by 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 only with /announcement on the site (as mentioned above) everything works normal, the problem is that when I call /advertisement/354 I can get the n variable get, but the full page CSS does not load. What might be going on?
Follow the code of index.php:
<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 someone help me?
NOTE: the include with view/... is because they are in another folder.
It happens because the link
/anuncio/354
is interpreted as directories, and then the css is searched within them(/anuncio/354/css/style.css
)– Leonardo Rodrigues