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 ^$ http://sub.example.com/somepage [L,R=301]
This re-directs sub.example.com to sub.example.com/somepage
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 ^$ http://bizuns.com/htaccess-redirect-examples$1 [R=301,NC,L]
This would re-direct sub.example.com to bizuns.com/htaccess-redirect-examples (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 ^ http://search.example.com/search/node/firstword+secondword+\%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 ^ http://search.example.com/search/node/FIRSTWORD+SECONDWORD+%1? [NC,L,R]