htaccess with friendly url not working (?)

1

I'm finishing a project, and I thought of putting a friendly URL, one that I had already used in another project, the same thing, I did not change anything, just the server and host of the site.

From: www.site.com/noticia?id=1 to www.site.com/noticia/1 however, it is adding a "/" at the end of everything ( www.site.com/noticia/1/ ), which is giving the "NOT FOUND" page.

In the other project I mentioned above, it is the same, same code, I just changed the information I get and return from the page that displayed the content, but the last "/" is giving the conflict, and I have no idea how remove it.

I looked in several sites to see if there was any way to remove it or even another one that did the same thing, but, without success, I looked here as well and nothing.

I just do not know if the host has any influence on it, since I do not usually mess around with .htaccess.

In the wamp it runs correctly, even without the .htaccess, however, on the host of this problem.

The .htaccess is like this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1.php/$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
ErrorDocument 403 //403.php
ErrorDocument 404 //404.php
ErrorDocument 500 //500.php

Display Page Code:

<?php 
include_once "assets/inc/head.php"; 
include_once "assets/inc/busca.php";
$Carro =  $_SERVER['PATH_INFO'];
$CarroN = $_SERVER['PATH_INFO'];
$CarroL = $_SERVER['PATH_INFO'];
$CarroF = $_SERVER['PATH_INFO'];
$muda_path = explode('/', $Carro );
$muda_path = explode('/', $CarroN );
$muda_path = explode('/', $CarroL );
foreach($muda_path as $carro_link){
    $CarroID = $carro_link;
    $CarroNome = $carro_link;
    $Carro_Link = $carro_link;
    $video_select = "SELECT * FROM carros WHERE 'id'='$CarroID' OR 'link_carro'='$Carro_Link' OR 'nome_carro'='$CarroNome'";
    $query = @mysql_query($video_select) or die (mysql_error());
}
if (mysql_num_rows($query) <= 0) {
    $vd = mysql_fetch_assoc($query);
    include_once "assets/inc/not_found.php";
    };?>

I'm still kind of new to programming since I move more with html and css, so the code can be kind of amateurish.

    
asked by anonymous 21.05.2017 / 12:18

1 answer

0

I usually use the following

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^noticia(|/)$ noticia.php
RewriteRule ^noticia/(.*)$ noticia.php?id=$1

I use it on my host and it never presented me problems.

    
21.05.2017 / 12:40