Rewritting URL by htaccess

When i click on a link it should redirect to for ex; www.domain.com/demo/item.php?item=abc&id=3 but in url it should show as www.domain.com/demo/abc/3

im Using

<IfModule mod_rewrite.c>
Options +SymlinksIfOwnerMatches
RewriteEngine on
RewriteRule ^demo/(.+) demo/item.php?item=$1&id=$2 [NC,L]

Please help

2 answers

  • answered 2018-09-19 06:24 Mukesh Jakhar

    You can try with this one, it will not redirect your URL but if you execute your URL (www.domain.com/demo/abc/3) it will be work.

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]
    

  • answered 2018-09-19 06:25 RamRaider

    You could try like this after adding the rewritebase directive

    RewriteEngine on
    RewriteBase /
    
    RewriteRule ^demo/([0-9a-zA-Z\s_]+)/([0-9]+)(/?)$ demo/item.php?item=$1&id=$2 [NC,L]