lehnert.dev/www/.htaccess
2025-04-21 17:35:59 +00:00

62 lines
2.0 KiB
ApacheConf

RewriteEngine On
RewriteBase /
# -------------------------------------------
# Rewrite /blog/<ID> to /blog.php?id=<ID>
# -------------------------------------------
RewriteRule ^blog/([^/]+)$ /blog/$1/ [L]
RewriteRule ^blog/([^/]+)/$ blog.php?id=$1 [L]
# -------------------------------------------
# Rewrite /sitemap.xml to /blog.php?id=<ID>
# -------------------------------------------
RewriteRule ^sitemap\.xml$ /sitemap.php [L]
# -------------------------------------------
# Rewrite some dummy urls to some funny af
# shit
# -------------------------------------------
RewriteRule ^(wp\-admin|wp\-login|cms\-admin).*$ /dummy/wp-login.html [L]
RewriteRule ^.*?wp-config\.php$ /dummy/wp-config.php.txt [L]
RewriteRule ^.*?profile\.php$ /dummy/profile.php.txt [L]
RewriteRule ^.*?phpinfo\.php$ /dummy/phpinfo.php.html [L]
RewriteCond %{REQUEST_URI} !^/dummy/sftp-login.json$
RewriteRule ^\..*?\.json$ /dummy/sftp-login.json [L]
RewriteCond %{REQUEST_URI} !^/dummy/\.env$
RewriteRule ^.*?\.env$ /dummy/.env [L]
RewriteRule ^(typo|admin|login|dashboard).*$ /dummy/kaffee.php [L]
# ----------------------------------------------------
# Rewrite /lib/* or /blog/* to /error.php?code=404
# with 404 response code (internal rewriting)
# ----------------------------------------------------
RewriteCond %{REQUEST_URI} ^/(lib)(/.*)?$
RewriteRule ^ - [R=404,L]
ErrorDocument 404 /error.php?code=404
# ----------------------------------------------------
# Custom error handler for all other errors
# Sends proper status code to client
# ----------------------------------------------------
ErrorDocument 400 /error.php?code=400
ErrorDocument 401 /error.php?code=401
ErrorDocument 403 /error.php?code=403
ErrorDocument 500 /error.php?code=500
ErrorDocument 502 /error.php?code=502
ErrorDocument 503 /error.php?code=503
# RewriteEngine On
# ErrorDocument 404 /404.php
# RewriteRule ^b/([0-9]+)$ /blog.php?id=$1 [QSA,L]
# RewriteRule ^/lib - [R=404,L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^.*$ - [R=404,L]