# Enable the rewrite engine
RewriteEngine On

# Set the base directory (adjust if your site is in a subdirectory)
RewriteBase /ManakWebsite/

# Remove .php extension from URLs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/?$ $1.php [NC,L]

# Blog post URL rewriting
RewriteRule ^blog-details/([^/]+)/([^/]+)/?$ single-post.php?category=$1&slug=$2 [L,QSA,NC]

# Redirect old single-post.php?slug=xxx to new URL format
RewriteCond %{THE_REQUEST} /single-post\.php\?slug=([^&]+) [NC]
RewriteRule ^ /ManakWebsite/blog-details/general/%1? [R=301,L]

# Handle 404 errors
ErrorDocument 404 /ManakWebsite/404.php

# Prevent directory listing
Options -Indexes
