I'm having problem with .htaccess that rewrite my url. I created a simple dynamic website and I cant figure how to fix it. This is my login url localhost/foss/ then after successful login the user will be redirected to localhost/foss/main
here is the code of my .htaccess
RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?p=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?p=$1
and here is my php that handle include files depending on the p value.
<?php
$page = $_GET['p'];
$pages = array('home', 'inv_view', 'inv_add', 'inv_delete', 'inv_edit', 's_view', 's_add', 's_delete', 'change_pass', 'register', 'logout');
if (!empty($page))
{
if(in_array($page, $pages))
include $page . '.php';
else
echo 'Page not found!';
}
else
include 'home.php';
?>
this is working fine, the only weird things that going on, is after the user is redirected to the localhost/foss/main, the .htaccess rewrite the url to localhost/foss/main/?p=main, but when i choose a link like localhost/foss/main/home it will work normally. how can i get rid of the ?p=main after the user login and redirected to localhost/foss/main