htaccess Basics in Apache
From the Apache cheat sheet ยท htaccess & URL Rewriting ยท verified Jul 2026
.htaccess Basics
Common .htaccess configurations
apache
# Enable rewrite engine
RewriteEngine On
# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
# Custom error pages
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html๐ .htaccess provides directory-level config
๐ Requires AllowOverride All in vhost
โก Can impact performance if overused
๐ฏ Great for shared hosting environments
Continue with Apache
Save the full cheat sheet or work through every related task.