How to add .htaccess file in your local host? means what should be writte in file?

Solution:

Your wordpress installation must be in the root folder of htdocs or in a subfolder such as blog.

For example, if you install your WP in blog folder under htdocs, you can then access your website via localhost/blog URL

EDIT:

Please try saving this code as .htaccess file and put it in the /wordpress folder where your wp-config.php and index.php are located.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress