Difference between revisions of "Htaccess"

(Restrict access to users on campus)
(Redirecting)
Line 22: Line 22:
  
 
<code><nowiki>Redirect 301 /relative/source http://gustavus.edu/absolute/target</nowiki></code>
 
<code><nowiki>Redirect 301 /relative/source http://gustavus.edu/absolute/target</nowiki></code>
 +
 +
===URLs with spaces===
 +
Although URLs should never contain spaces, if you happen to be redirecting either to or from a [[URL]] that has a space in it, use quotation marks:
 +
 +
<code><nowiki>Redirect 301 "/relative/source with spaces" http://gustavus.edu/absolute/target</nowiki></code>
  
 
==External link==
 
==External link==
 
* [http://thejackol.com/htaccess-cheatsheet .htaccess Cheatsheet] &mdash; the jackol's den
 
* [http://thejackol.com/htaccess-cheatsheet .htaccess Cheatsheet] &mdash; the jackol's den

Revision as of 16:28, 11 October 2006

.htaccess (Hypertext Access) is the default name of Apache's directory-level configuration file. It provides the ability to customize configuration directives defined in Apache's main configuration file, to modify the access to and behavior of certain directories on our web server.

Creating .htaccess files

It's important that you use a text editor which does not place carriage returns at the end of lines, as these can cause problems when Apache is trying to read the files. Almost every text editor on Windows will stick these carriage returns in, so we recommend you SSH into charlotte.gac.edu and create your file with one of the many editors installed on the server, such as emacs, vi, pico, or nano.

Password-protecting directories

The most common reason for using a .htaccess file is to restrict access to a directory.

Restrict access to users on campus

order deny,allow
deny from all
allow from 138.236.

Restrict access to specific user(s)

Restrict access to specific LDAP group(s)

Redirecting

If an entire directory has moved permanently, the smoothest and most efficient way to redirect visitors is using a 301 redirect:

Redirect 301 /relative/source http://gustavus.edu/absolute/target

URLs with spaces

Although URLs should never contain spaces, if you happen to be redirecting either to or from a URL that has a space in it, use quotation marks:

Redirect 301 "/relative/source with spaces" http://gustavus.edu/absolute/target

External link

  • — the jackol's den