Redirects and .htaccess examples

Here are some basic .htaccess snippets you can copy and paste.

Re-direct the front page of a sub domain to a specific page on the same site

RewriteCond %{HTTP_HOST} sub\.example\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ [L,R=301]
This re-directs to

Re-direct only the front page of a sub domain to a directory on a different website

RewriteCond %{HTTP_HOST} ^sub\.example\.com [NC]
RewriteRule ^$$1 [R=301,NC,L]
This would re-direct to (this page).

Redirect Using Plus Sign in the Destination URL

This example was for passing an input form to Solr Apache from one website to another. I needed to pass the query with a plus + sign in front of the destination URL.
RewriteCond %{THE_REQUEST} /search/node/\?find=([^\s]+) [NC]
RewriteRule ^\%2B%1? [NE,L,B]
The plus sign is added by using %2b in the RewriteRule and the [NE] (No escape)

This was the old version using plus signs instead of spaces
RewriteCond %{THE_REQUEST} /search/node/\?find=([^\s]+) [NC]
RewriteRule ^ [NC,L,R]