Redirect all URLs to HTTPS with mod_rewrite
RewriteEngine on
RewriteRule ^.*$ https://%{SERVER_NAME} [R](This can go inside a VirtualHost if you just want the rule to apply to that virtual host.)
Redirecting Requests for Multiple Domains To Just One Domain
RewriteEngine on
RewriteRule ^.*$ http://someotherdomain.com [R]
Note: Remove any '>>' characters that the html on this page adds to that url if you copy/paste it.
Or, say you wanted certain urls to redirect from the regular domain to an https/ssl secured domain you could do something like:
RewriteEngine on
RewriteRule ^/store/(.*)$ https://someotherdomain.com/store/$1 [R]
Redirecting all requests for .html files to a PHP script.
This comes in handy if you to convert an existing set of static HTML files over to just one PHP script, without breaking all your existing URLs.
eg:
http://your.com/someold.html would still work, but content would be generated by the 'some.php' script.
<Location />
RewriteEngine on
RewriteBase /
RewriteRule .html some.php [T=application/x-httpd-php]
</Location>
Blocking Image Hotlinking
Sometimes other websites will reference images located on your server. This consumes your bandwidth and some consider it stealing and it is impolite in the very least. To prevent this from happening, you can use a simple mod_rewrite rule (This can go inside a virtual host definition if you want it to just apply to that virtual host):
RewriteEngine on
RewriteCond %{HTTP_REFERER} !=""
RewriteCond %{HTTP_REFERER} "!^http://yourdomain.com/.*$" [NC]
#the following will block requests for 3 image types, but you can extend this to any
#resource type
RewriteCond %{REQUEST_URI} ".(jpg|gif|png)$"
RewriteRule .* - [F]