Redirects
To redirect from one URL to another, add the following line to the .htaccess file:
Redirect [status] "sourcepath" "targeturl"
Where:
Redirect is the keyword that specifies a redirect is to be performed.
status is an optional keyword that indicates whether this redirect is expected to change over time. If omitted, or specified as the default, "temp", browsers will check with the server every time the source URL is accessed. If specified as "permanent", the redirect isn't expected to change, and browsers will cache the redirect.
Permanent redirects have search engine optimization advantages in that the search engine ranking will transfer to the new URL.
sourcepath is the path part of the URL to be redirected. The path must not include the protocol (https://) or hostname and must start with a slash.
targeturl is the URL to redirect to. If the target url is on the same hostname as the source url, the protocol and hostname should be omitted.
The .htaccess file must be located in the directory containing the sourcepath or in a directory above. Typically in K-State's configuration, if an .htaccess file exists for a site, it is located in the site's root directory.
Examples
Directory renamed within a website
Suppose that in Provost's website, the Office of New Engagement, with the URL:
www.k-state.edu/provost/one
is renamed to the Tower of Web Operations with the URL:
www.k-state.edu/provost/two
Furthermore, suppose that the website structure is essentially unchanged. Until all links have been updated, a redirect can direct people that use the old URL to the new URL. The following line in the .htaccess file, in the provost folder, will do the redirect:
Redirect permanent "/one" "/two"
Characters in the original URL after sourcepath are appended to the target URL. For example, the URL:
www.k-state.edu/provost/one/about/staff.html
will be redirected to
www.k-state.edu/provost/two/about/staff.html
To redirect from one URL to another, add the following line to the .htaccess file:
Notes
Redirects should not be used an excuse to let old URLs persist indefinitely. After a department or directory rename, redirects are an important tool to avoid broken links. However, over time links should be changed to directly go to the target URL.