• Collection of useful Apache redirects, rewrites, directives and reminders

    These are a slew of rewrite and redirection commands for Apache that can be setup in .htaccess or other site configuration files. In some cases there are multiple ways of doing things that might work in one situation but not another. I have a love/hate relationship with mod_rewrite, as I think many do, but in the end it is a powerful tool that can do so much that it is indispensable.

    ** IMPORTANT – Anywhere you see RewriteXXXXX, make sure you have “RewriteEngine On” to enable it! **

    Custom error pages:

    ErrorDocument 400 /errors/400.html
    ErrorDocument 401 /errors/401.html
    ErrorDocument 403 /errors/403.html
    ErrorDocument 404 /errors/404.html
    ErrorDocument 500 /errors/500.html

    Read the rest of this entry »

  • Reverse Proxy from IIS Website to WordPress

    Our client has a corporate site at www.domain.com hosted on IIS and the blog hosted on a subdomain on a separate LAMP server at blog.domain.com. Our client feels serving their blog up under www.domain.com/blog will help their SEO and they will rank better (this is debateable but what client wants is what they will get).

    The objective of this project is to serve a wordpress site on a linux server under a subdirectory on IIS. In order to accomplish this we need to setup IIS to act as a reverse proxy, thus serving the the wordpress site under the desired blog subdirectory.

    The first step is to make sure your version of IIS is compatible (IIS 7+). Once you have determined this, you will need to install the Application Request Routing Module. The easiest way to go about installing these is using the

    Read the rest of this entry »

  • 301 redirect all subdomains to new domain on apache

    While trying to consolidate many subdomains under one new domain on apache we had to add the following into the sites configuration file to redirect the multiple subdomains to one. This could be added into the .htaccess as well.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^newdomain.com$ [NC]
    RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301]

    Read the rest of this entry »

  • Apache redirect for wildcard domains

    We recently had to redirect a wildcard domain to another wildcard domain using Apache redirects. It is assumed you have already enabled mod_rewrite, if not make sure you enable that apache module before you try adding this rule.
    Read the rest of this entry »