<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /booklinks/
    
    # Handle permalinks
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?permalink=$1 [L,QSA]
    
    # Security measures - UPDATED SECTION
    <FilesMatch "\.php$">
        Order allow,deny
        Allow from all
    </FilesMatch>
    
    <FilesMatch "\.(tpl|ini|log|sh|inc|txt)$">
        Order allow,deny
        Deny from all
    </FilesMatch>
</IfModule>

# Prevent directory listing
Options -Indexes

# Set character encoding
AddDefaultCharset UTF-8