cat > ~/public_html/whatsappcrm/.htaccess << 'EOF'
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /whatsappcrm/
    
    # Remove trailing slash
    RewriteRule ^(.+)/$  $1 [L,R=301]
    
    # Don't process requests for actual files/directories
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    
    # Proxy all requests to Node.js server
    RewriteRule ^(.*)$ http://localhost:4000/$1 [P,L]
</IfModule>

<IfModule mod_proxy.c>
    ProxyPreserveHost On
    ProxyPassReverse / http://localhost:4000/
</IfModule>
EOF