url rewriting - Url rewrite with parameter using .htaccess -


i have url page.php?id=param creating dynamically.

in url page.php , param dynamic html link looks

<a href="page.php?id=param">link</a> 

i need url

mydomain.com/param 

and should go page.php , parameter id should used page.php.

this code i'm using right

# externally redirect /dir/foo.php?id=123 /dir/foo/123 rewritecond %{the_request} ^get\s([^.]+)\.php\?id=([^&\s]+) [nc] rewriterule ^ %1/%2? [r,l]  # internally forward /dir/foo/12 /dir/foo.php?id=12  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f   rewriterule ^([^/.]+)/?([^/.]+)?/?([^/.]+)?/?([^/.]+)?$ /$1.php?id=$2 [qsa,l] 

but rewrite follows:

mydomain.com/page/param 

the required output should be:

mydomain.com/param 

rewriteengine on rewriterule    ^page/([a-za-z0-9-]+)/?$    page.php?id=$1    [nc,l]  

l (last - stop processing rules)
nc (case insensitive)

also view tutorial url rewriting beginners


Comments