Common .htaccess Rules and What They Do
The .htaccess file gives you a lot of control over how your website works. Here's a handy reference of common rules you might use on your dotCanada shared hosting account.
Force HTTPS
Redirect all HTTP traffic to the secure HTTPS version of your site:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Block a Specific IP Address
Deny access to a visitor from a specific IP:
Deny from 123.456.789.0Disable Directory Listing
Prevent visitors from browsing your folder contents when no index file exists:
Options -IndexesSet a Custom Error Page
Show a friendly custom page for 404 errors:
ErrorDocument 404 /404.htmlIncrease PHP Memory Limit
Override the default PHP memory limit for your account:
php_value memory_limit 256MSet Default Character Encoding
AddDefaultCharset UTF-8Protect a File
Block direct access to a sensitive file like wp-config.php:
<Files wp-config.php>
Order allow,deny
Deny from all
</Files>A Final Note
Always test changes on a staging site or keep a backup of your working .htaccess before editing. If something goes wrong, contact our support team and we'll help you sort it out.
100% Satisfaction Guarantee
We're so confident you'll love dotCanada that we offer a 30-day money-back guarantee. Not satisfied? Get a full refund, no questions asked.
Ready to Get Started?
Join thousands of Canadian website owners who trust dotCanada for reliable, fast web hosting.
Get Started Today
