I would like to show my page URL:
www.mypage.com/?q=picture
Instead of:
www.mypage.com/picture.html
I don't know how to redirect the page I want to see. But the url should not show page extension I have tried something like this but it's not working:
<a href="?q=home" style="text-decoration: none; color: #1E90FF; font-size:25px;">Home</a>
<?php
if(isset($_GET['q']) && $_GET['q']!="" )
{
$ext=".php";
$page=$_GET['q'].$ext;
if(file_exists($page))
{
header('location:$page');
}
else
{
header('location:errorpage.php');
}
}
?>
Use .htaccess. Create a file called .htaccess and add the code below. Hope this works
#rewrite file
RewriteEngine on
RewriteRule ^?q=([0-9a-zA-Z]+) $1.html
The only problem is that i could go to www.mypage.com/?q=mario and it will look for mario.html.
If that doesn't work then uses this.
#rewrite file
RewriteEngine on
RewriteRule ^home home.html
RewriteRule ^picture picture.html
this will make www.mysite.com/picture display all the content just like viewing picture.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.