Auto-sync enabled

FlatlyPage

Version 1.0.0 • 54 files • 724.77 KB
.htaccess
# Modern PHP CMS - URL Rewriting
# Apache mod_rewrite configuration

RewriteEngine On

# Force HTTPS (uncomment in production)
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove .php and .html extensions from URLs
RewriteCond %{THE_REQUEST} \s/([^\s]+)\.(php|html) [NC]
RewriteRule ^ /%1 [R=301,L,NE]

# Protect sensitive directories - block direct access to data folder
RewriteRule ^data/.*\.php$ - [F,L]
RewriteRule ^data/.*\.json$ - [F,L]
RewriteRule ^config\.php$ - [F,L]
RewriteRule ^themes\.css$ - [F,L]

# BLOCK PHP execution inside extensions
RewriteRule ^extensions/.*\.php$ - [F,L]

# ALLOW static assets from extensions
RewriteRule ^extensions/.*\.(css|js|png|jpg|jpeg|gif|svg|webp|woff|woff2|ttf|eot|map|html)$ - [L]

# Admin routes
RewriteRule ^admin$ /admin/index.php [L]
RewriteRule ^admin/$ /admin/index.php [L]
RewriteRule ^admin/dashboard$ /admin/dashboard.php [L]
RewriteRule ^admin/logout$ /admin/logout.php [L]
RewriteRule ^admin/generate-hash$ /admin/generate-hash.php [L]

# Skip existing files and directories
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

# Check if .php version exists
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L]

# Check if .html version exists
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L]

# Page slug routing - catch-all for custom pages
# Routes like /about, /services, /contact etc.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9\-]+)$ /page.php?slug=$1 [L,QSA]

# Security Headers (if mod_headers is enabled)
<IfModule mod_headers.c>
    # Prevent MIME type sniffing
    Header set X-Content-Type-Options "nosniff"
    # XSS Protection
    Header set X-XSS-Protection "1; mode=block"
    
    # Clickjacking protection
    Header set X-Frame-Options "SAMEORIGIN"
    
    # Referrer Policy
    Header set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>

# Disable directory listing
Options -Indexes

# Protect .htaccess
<Files .htaccess>
    Order allow,deny
    Deny from all
</Files>

# Block access to data files directly
<FilesMatch "\.(php)$">
    <If "%{REQUEST_URI} =~ m#^/data/#">
        Require all denied
    </If>
</FilesMatch>

# Cache static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType font/woff "access plus 1 year"
    ExpiresByType font/woff2 "access plus 1 year"
</IfModule>

# Compression
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
    AddOutputFilterByType DEFLATE application/javascript application/x-javascript text/javascript
    AddOutputFilterByType DEFLATE application/json
</IfModule>

# PHP settings (if allowed)
<IfModule mod_php.c>
    php_flag display_errors Off
    php_flag log_errors On
    php_value error_log /path/to/error.log
</IfModule>