WE can create user friendly url using url rewriting with the help of htaccess file. It helps to make URLs with duplicate content should have canonical URLs specified for them. Also beneficial for search engine optimization(SEO) for url crawling and indexing.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/.]+)(?:/)?$ /index.php?ctrl=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)(?:/)?$ /index.php?ctrl=$1&id=$2 [L]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)(?:/.*)?$ /index.php?ctrl=$1&id=$2&tab=$3 [L]
</IfModule>
For a path like http://website.com/param1/, redirect to /index.php?ctrl=param1
For a path like http://website.com/param1/029, redirect to /index.php?ctrl=param1&id=029
For a path like http://website.com/param1/029/param2/, redirect to /index.php?ctrl=param1&tab=param2
For a path like http://website.com/param1/029/param2/anything-can-go-here, redirect to /index.php?ctrl=param1&tab=param2 and ignore the rest of the path.
0 Comment(s)