'rewiteRule .haccess convert from one url directory to url paramter [duplicate]

hello people I want to convert from this

http://www.example.com/10/slug-of-product/lang=EN

/10/ it' required

/slug-of-product/ optional

lang=EN optional

if the above url is entered and there is not file or directory with this URL I want to get run this

http://www.example.com/view.php?id=10&slug=slug-of-product&lang=EN

this what I tried so far

# if not file
RewriteCond %{REQUEST_FILENAME} !-f
# if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([a-z]+)/lang=([a-z]+)/?$ view.php?pn=$1&slug=$2&lang=$3 [QSA,L]

problem! not working

the site can't load any file like images ...

cus I don't have those diractories



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source