i am trying to implement seo friendly url to my website. for page where no parameter passed, the url becomes fine i.e., without php extension but where i am sending variable parameter, it does not change. Please check below 2 type of code i try to implement.
First code in htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ makeurl.php?url=$1 [QSA,L]
makeurl.php code:
<?php
//echo "<pre>";
//print_r($_SERVER);
$hid = $_GET['hid'];
$request = $_SERVER['REQUEST_URI'];
//echo "<br>";
$router = str_replace('/wavehotels', '', $request);
if($router == '/'){
include('index.php');
}elseif($router == '/hotels'){
include('hotels.php');
}elseif($router == 'hotel-detail' || preg_match("/hotel-detail\/[0-9]/i", $router)){
include('hotel-detail.php');
}elseif($router == '/destinations'){
include('destinations.php');
}elseif($router == '/about-us'){
include('about-us.php');
}elseif($router == '/blogs'){
include('blogs.php');
}elseif($router == '/contact-us'){
include('contact-us.php');
}else{
include('404.php');
}
?>
i m getting result for nornal pages:
www.abc.com/about.php is result in www.abc.com/about
but the issue is in where parameter passed like www.abc.com/product.php?id=2
no change in this url, i want the result like www.abc.com/product/2
any input will be appreciated.
Thanks
Himanshoo