I need to know how I change my site url my I try url routing what is not work
my site product url is http://www.shahilibas.in/product.php?p_id=5
and I want seo friendly url like http://www.shahilibas.in/product.php/5
I try this code for url routing
function getCurrentUri()
{
$basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/';
$uri = substr($_SERVER['REQUEST_URI'], strlen($basepath));
if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?'));
$uri = '/' . trim($uri, '/');
return $uri;
echo $uri;
}
2
Answers
You need to add Rewrite Rule to .htaccess file . Create new text file give it name ‘.htaccess’ without quotes .
In Your .htaccess File Write the Code Below and Press Ctrl + s To save your File
You can add following code in your .htaccess file and save
Then your url will be like this
http://www.shahilibas.in/5
Which is more url friendly. Showing php file in url is not good for SEO.