Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Create user friendly url using htaccess

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 101
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: