# Clean URLs: hide the .php extension (rooms.php -> /rooms, admin/login.php -> /admin/login)
# Requires Apache mod_rewrite and AllowOverride All (default in XAMPP/WAMP/cPanel).
Options -MultiViews
DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteEngine On

# 0) Never show /index or /index.php: send them to the folder itself (domain root, or /admin/).
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s[^\s?]*/index(\.php)?[\s?] [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index(\.php)?$
RewriteRule ^ %1 [R=301,L]

# 1) If someone opens a URL that ends in .php, send them to the clean URL (query string is kept).
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s[^\s?]*\.php[\s?] [NC]
RewriteRule ^(.+)\.php$ $1 [R=301,L]

# 2) Serve /rooms (no extension) from rooms.php internally.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
</IfModule>
