Apache webserver and rewrite rules Here are some rewrite codes I sometimes use. Rewrite is a very powerful Apache module and so almost everything is possible. Some examples. To rewrite your http://www.oldsite.org/something to the new URL http://www.newsite.org/something, you can use the next code: RewriteCond %{HTTP_HOST} ^www\.oldsite.org [NC] RewriteRule ^ http://www.newsite.org%{REQUEST_URI} [L,R=301] To do an action when the user don't have a special cookie, for example to force somebody to the login page or redirect him to a welcome page. Take a look at the second rule. This one prevents looping over these rule again and again. RewriteCond %{HTTP_COOKIE} !logincookie RewriteCond %{QUERY_STRING} !page=login RewriteRule ^(.*)$ %{REQUEST_URI}?page=login [L,R] To rewrite a request if it's a search result from google. RewriteCond %{HTTP_REFERER} ^http://www\.google [NC] RewriteRule ^ http://www.somewhere.com/something.gif [R] To simple forward your request to your internal server2 on port 8080: RewriteEngine On RewriteRule ^/app/(.*)$ http://server2:8080/app1/$1 [P] The website semalt.com is spamming us with referers that actually don't exsists. To clean you statistics and send the basterts back to where they came from: # Block semalt.com referer RewriteEngine on RewriteCond %{HTTP_REFERER} semalt\.com [NC,OR] RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*semalt\.com [NC,OR] RewriteCond %{HTTP_REFERER} ^http://([^.]+\.)*kambasoft\.com [NC,OR] RewriteCond %{HTTP_REFERER} youtube-downloader\.savetubevideo\.com [NC] RewriteRule (.*) http://www.semalt.com [R=301,L]