I have these .htaccess rewrite rules on my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^materia/([^/]+)/?$ article.php?slug=$1 [L,NC]
RewriteRule ^([^/]+)/?$ index.php?slug=$1 [L]
</IfModule>
Inside a PHP class, I have a function which detect if URL have a specific variable:
if (isset($_GET['slug'])) {
$slug = $_GET['slug'];
$file = 'partials/'.$slug.'.php';
} else {
$slug = 'home';
$file = 'partials/home.php';
}
It's working fine. But when I remove the # from the second rule, the function start to return index.php
as a value from variable slug
when the URL is http://website.test/site/