Support Center

Cheat Sheet for .htaccess

Last Updated: Aug 20, 2015 04:11PM CDT

Jackol's Den

Great cheatsheet for .htaccess with a good range of examples for most needs:


Official documentation here:

Mod_Rewrite Rules

Official documentation:

Miscellaneous Helpful Links:

Redirect All Links to WWW

Some site owners are concerned that users should always be redirected from to, or from to This can affect cookies, etc. IBBoard solved this issue with some .htaccess lines.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{THE_REQUEST} !^[^\]+\ /foldername(\?.*)?\ .*$
RewriteRule ^(.*)$$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^$
RewriteRule ^$ [R=301,L]


Check that the host doesn't match and check that the request isn't just the current folder without a trailing slash (or the current folder without a trailing slash with a query string) and then do a rewrite rule on that. The next rule then catches the host not maching but the request being /ibboard (i.e. some accessing and not Both rules then rewrite the request to use the required domain.

The two rules are required as a single rule with only the %{HTTP_HOST} condition causes requests to "" to be incorrectly rewritten to "".
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found