'Redirection not working with .htaccess file
I am using htaccess to hide GET variables from the URL. I am having a problem. Myy project structure is something like this:
--project
index.php
/views
login.php
example.php
/user
dashboard.php
So, when I use something like "localhost/project/login", I am correctly redirected to the login.php page. But when I do something like "localhost/project/user/dashboard", I get an Apache generated 404 Not Found response.

This is what I am using in PHP to include the pages with the GET variables:
PHP code:
<?php
if(isset($_GET['page'])) {
$page = $_GET['page'].'.php';
if(is_file('views/'.$page)) {
include 'views/'.$page;
} else {
echo 'Page does not exist';
}
?>
htaccess file:
RewriteEngine on
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [NC]
Can anybody give me some guidance? I don't have experience with .htaccess files
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
