List your Apache virtual hosts

21/05/2010
apache2ctl -t -D DUMP_VHOSTS
No Comments

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

Disable open_basedir for a domain in Plesk

4/10/2005
  1. Move to the conf directory of the domain
    cd /home/httpd/vhosts/domain.com/conf
  2. Create a file called vhost.conf (or vhost_ssl.conf for https). Paste in the following three lines:
    <Directory /home/httpd/vhosts/domain.com/httpdocs>
    php_admin_value open_basedir none
    </Directory>
  3. Lastly, rebuild the domain configs by running the following command:
    /usr/local/psa/admin/sbin/websrvmng -a -v
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