Apache: rewriting requests for iPhone and iPod Touch

4/08/2009

This snippet will rewrite all requests to the page iphone.html when viewed on iPhone or iPod Touch. Requests for .gif and .css files are not rewritten, so you can include stylesheets and images in your iPhone-specific page.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari
RewriteRule !\.(gif|css)$ /iphone.html  [L]

Source: http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/

No Comments

Apache: force all http requests to redirect to https

21/08/2008
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
No Comments

Redirecting all requests to a single page

19/09/2005

Useful when closing a site for maintenance:

RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^xxx.xxx.xxx.xxx$
RewriteRule !\.(gif|css)$ closed.php

(Where xxx.xxx.xxx.xxx is your local IP address.)

Allows requests from the specified IP, but everyone else gets the closed page. Allows requests for .gif and .css files so we can display the website logo on the closed page, and use the stylesheet.

No Comments