One of the bonuses of attending the WMW Pubcon is that they mail attendees a cd of all of the PowerPoint presentations that were used in the sessions. One of the presentations was by a company called TrueLocal, where they discussed using mod rewrite for various things. Now, I do not claim to have much knowledge about mod rewrite, so I cannot explain any of the code they showed us. But, I thought you might like to have the code in case you need it. So, without further explanation, here it is.
Folder move (redirect) - moving a folder from an old location to a new one:
RewriteRule ^olddir/(.*)$ /newdir/$1 [R=301,L]
Serving content transparently - shortening urls for search engines
RewriteRule ^([^/]+)/(.+)$ /file.php?Dir=$1&file=$2 [L]
Deny access to an IP:
RewriteCond %{REMOTE_ADDR} ^123.45.67.[9]$
RewriteRule ^/.* - [F]
Serve Different Content to a UA/IP:
RewriteCond %{HTTP_USER_AGENT} ^Jakebot
RewriteRule ^page1.html$ /special-page.html [F]
Serve Image Based Upon Referrer - Prevent image theft:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !.*/valid-page.htm
RewriteCond %{REQUESTED_FILENAME} ^specific-image-name.jpg$
RewriteRule .*.(gif|png|jpe?g) https://www.example.org/funnypic.jpg
Please make sure you backup your .htaccess file before adding this code to it, in case you need to revert back.
Thanks for the tips, Donna. Hopefully I’ll be able to use them.