Code Snippets ApacheConf

Short texts ApacheConf 🧑‍💻 Code snippets ApacheConf ✍️ Reading lists ApacheConf 👀

Enable Gzip compression in Laravel assets #laravel #php

AddOutputFilterByType DEFLATE application/json AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/vnd.ms-fontobject AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE font/opentype AddOutputFilterByType DEFLATE font/otf AddOutputFilterByType DEFLATE font/ttf AddOutputFilterByType DEFLATE image/svg+xml AddOutputFilterByType DEFLATE image/x-icon AddOutputFilterByType DEFLATE text/css AddOutputFilterByType […]

.htaccess file for websites hosted in cpanel

RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] # BEGIN WordPress RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteRule ^index\.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$ RewriteCond […]

.htaccess to add CORS to your website

# Add these three lines to CORSify your server for everyone. Header set Access-Control-Allow-Origin “*” Header set Access-Control-Allow-Methods “GET,PUT,POST,DELETE” Header set Access-Control-Allow-Headers “Content-Type, Authorization”

Stupid quick script to create new domain – in progress

#!/bin/bash echo “User>”; read TUSER echo “Pass> (do not exceed 16 chars)”; read TPASS echo “Domain>”; read TDOMAIN echo “Alias>”; read TALIAS echo “Database name>”; read TDBNAME VHOSTPATH=/etc/apache2/sites-available/$TDOMAIN.conf useradd –password “$TPASS” -m -s /bin/bash $TUSER mkdir /var/www/$TDOMAIN ln -s /var/www/$TDOMAIN /home/$TUSER/public_html cp ~/sitetemplate.conf $VHOSTPATH # APACHE vhost sed “s/\$TDOMAIN/$TDOMAIN/g” -i $VHOSTPATH sed “s/\$TALIAS/$TALIAS/g” -i $VHOSTPATH […]

Apache2 configuration for Next.js application with SSL certificate, generated by mkcert.

ServerName example.loc ServerAlias *.example.loc Redirect permanent / https://example.loc/ ServerName example.loc ServerAlias *.example.loc ProxyPreserveHost On ProxyRequests Off ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ SSLEngine on SSLCertificateFile /etc/apache2/ssl-certificates/example.loc.pem SSLCertificateKeyFile /etc/apache2/ssl-certificates/example.loc-key.pem