I am recently working on a php project. I created the template for my site and design the pages. However, the navigation between pages is like the following:
http://localhost:81/x/y/index.php
and when I want to navigate to another page the URL will be like: http://localhost:81/x/y/second.php
how can I make the following URL takes me to the second.php page?
http://localhost:81/x/y/index.php?page=second
Thanks.
Unless I am misunderstanding something, put this at the top of the index.php page:
<?php
if($_GET['page'] == "second")
{
$newURL = 'http://localhost:81/x/y/second.php';
header('Location: ' . $newURL);
}
?>
I would add a bit more to it to make it secure but the simple answer would be...
if(isset($_GET['page'])
{
require '/path/to/folder/' . $_GET['page'] . '.php';
}
If it is a redirection that you want, you could also do.
if(isset($_GET['page'])
{
header('Location: ' . $_GET['page'] . '.php');
}
Try this Rule:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^x/y/index.php?page=(.*)$ http://localhost:81/x/y/$1.php [R=301,L]