Redirection: How to redirect a page or directory using an .htaccess file

This article contains information for users who want to redirect an outdated web page / directory to current, relevant content. These steps will work on Copland hosted sites. This CANNOT be used on CampusPress WordPress sites.

Redirect from a directory to a file

This .htaccess file is placed within the old directory.

RedirectMatch 301 "^/olddir(/.*)?$" "https://www.udel.edu/newdir/"

 

Redirect from a file to a directory

This .htaccess file is placed within the old directory where the file is located.

Redirect 301 page.html "https://www.udel.edu/dir/"

 

Redirect an old directory to a new directory

This redirects an old directory (/old_dir) to a new directory (/new_dir). This .htaccess file is placed within the old directory.

Redirect 301 /old_dir "/new_dir"
 

Redirect a file to another file in another directory

This redirects a file (index.html) to a new file in a new directory (/mydir/index.html). This .htaccess file is placed within the old directory.

Redirect 301 /index.html "/mydir/index.html"

 

RewriteEngine directives restrictions and security

Due to security risks +FollowSymLinks is disabled on Copland. This also prevents the use of the RewriteEngine directive. Use the redirect techniques above to get around this.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^old_dir/(.*)$ /new_dir/$1 [R=301,NC,L]

Details

Article ID: 510
Created
Thu 8/1/19 8:43 AM
Modified
Fri 3/4/22 9:59 AM