.htaccess file contains below excerpt to block specific files and folders.RewriteCond %{REQUEST_URI} wp-login.php|wp-adminRewriteCond %{REMOTE_ADDR} !^123.456.789.RewriteRule . - [R=404,L]I need to replace 123.456.789 field with my current IP which can be retrieved from:w -h | awk '{print $3}' | head -1How can I replace IP field in .htaccess file by my current IP grabbed from w and save it again to .htaccess file?
How to Replace IP field in Rewrite Condition
htaccess
I found the solution. In case someone needs, it is:sed -i s/RewriteCond %{REMOTE_ADDR} \!\^[0-9,\.]*/RewriteCond %{REMOTE_ADDR} \!\^$(w -h | awk '{print $3}' | head -1)/g .htaccess