Skip to content Skip to navigation

Redirect from AFS to sites.stanford.edu and exclude one directory

Author: 

We have recently moved a website from /afs/ir/group/name-of-group/ to sites.stanford.edu platform with url http://new-name.stanford.edu and we wanted to redirect everything from old site to new site, except forms that are built using Form Builder.

I wanted to share our .htaccess code for those who are following the same trail...


RewriteEngine On
RewriteCond %{REQUEST_URI} !/group/name-of-group/forms [NC]
RewriteCond %{HTTP_HOST} !new-name.stanford.edu$ [NC]
RewriteRule ^(.*)$ http://new-name.stanford.edu/$1 [L,R=301]

An alternative method is to exclude only Formbuilder forms:


# ignore Web Forms Service URLs
RewriteCond %{REQUEST_URI} !.*\.(fb|FB|Fb)$