RewriteEngine On RewriteBase / # Rewrite to HTTPS: RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Rewrite thewebsite.com -> www.thewebsite.com RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.thewebsite\.com [NC] RewriteRule (.*) http://www.thewebsite.com/$1 [R=301,L] # Discuss rewrite rules RewriteRule ^forums/thread/([0-9]+)/(.*)$ forums/?action=thread&thread=$1 [L,QSA] RewriteRule ^forums/u/(.+)$ forums/?action=user&user=$1 [L,QSA] RewriteRule ^forums/board/([0-9]+)/(.*)$ forums/?action=board&board=$1 [L,QSA] RewriteRule ^forums/category/([0-9]+)/(.*)$ forums/?category=$1 [L,QSA] RewriteRule ^forums/(.+)$ forums/?action=$1 [L,QSA] RewriteRule ^forums/(.+)/$ forums/?action=$1 [L,QSA] # The Friendly URLs part RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteEngine On RewriteBase / # Rewrite to HTTPS: RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Rewrite thewebsite.com -> www.thewebsite.com RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.thewebsite\.com [NC] RewriteRule (.*) https://www.thewebsite.com/$1 [R=301,L] # Discuss rewrite rules RewriteRule ^forums/thread/([0-9]+)/(.*)$ forums/?action=thread&thread=$1 [L,QSA] RewriteRule ^forums/u/(.+)$ forums/?action=user&user=$1 [L,QSA] RewriteRule ^forums/board/([0-9]+)/(.*)$ forums/?action=board&board=$1 [L,QSA] RewriteRule ^forums/category/([0-9]+)/(.*)$ forums/?category=$1 [L,QSA] RewriteRule ^forums/(.+)$ forums/?action=$1 [L,QSA] RewriteRule ^forums/(.+)/$ forums/?action=$1 [L,QSA] # The Friendly URLs part RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
<ifmodule mod_deflate.c> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript </ifmodule> <IfModule mod_expires.c> ExpiresActive On ExpiresDefault "access plus 10 days" ExpiresByType text/css "access plus 1 week" ExpiresByType text/plain "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-icon "access plus 1 year" </IfModule>
Occupational hazzard
If you want to take things further you might try adding this to the end of your .htaccess file. It should help speed things up some, assuming your server supports deflate.
<ifmodule mod_deflate.c=""> AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript text/javascript </ifmodule> <ifmodule mod_expires.c=""> ExpiresActive On ExpiresDefault "access plus 10 days" ExpiresByType text/css "access plus 1 week" ExpiresByType text/plain "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 week" ExpiresByType application/x-icon "access plus 1 year" </ifmodule>
GZIP Details: http://salscode.com/tutorials/2009/10/15/gzip-htaccess/
Expires: http://css-tricks.com/snippets/htaccess/set-expires/
The first bit of code reduces the file size of text based content. You could add images, but I wouldn't recommended it. The second bit tells the browser to cache the files saving additional bandwidth and reduce server requests. You might want to leave the second half off during development.
This is just scratching the surface of performance tweaks, you can do some really awesome stuff leveraging services like CloudFlare and www.jsdelivr.com.