Today i will discuss how to create SEO friendly URL with dynamic content using PHP and .htaccess mod redirection. Friendly URLs improves your site search engines ranking. Before trying this you have to enable mod_rewrite.so module at httpd.conf. It’s simple just few lines of PHP code converting title data to clean URL format. Follow my below written steps and run your project.
Normal URL: www.yourcompany.com/profile.php?id=1
SEO Friendly Url after rewrite.
www.yourcompany.com/profile/1
To create SEO fridndly Url please follow the below process.
1. Create a .htaccess file and upload on the server root folder.
2. Open and write the bellow code on .htaccess file.
3. Save the file.
RewriteEngine On
RewriteBase /
RewriteRule ^index?$ index.php
RewriteRule ^test/([0-9]+) test.php?u=$1
Get velue from the Url
<?php
echo $_GET['u'];
?>
if you are not geting value from the above code the use below code to fetch value
<?php
$uri = $_SERVER["REQUEST_URI"];
$uriArray = explode('/', $uri);
$link = $uriArray[1];
$id = $uriArray[2];
echo $id;
?>
No comments:
Post a Comment