Htaccess: Introduction: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(→‎Whats in a name: Punctuation and grammatical changes; some clarification.)
(Folder to Directory.)
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
{|  
{|  
|[[Image:uc_small_logo.gif | MPG UniCenter]] ||
 
.htaccess:  
.htaccess:  
[[Htaccess: Introduction | Introduction]] |   
[[Htaccess: Introduction | Introduction]] |   
Line 18: Line 18:
'''.htaccess''' - ''Apache directory-level configuration file''
'''.htaccess''' - ''Apache directory-level configuration file''
|}
|}
The '''.htaccess''' file is a simple ASCII file it provides an easy method to extend the Apache configuration file you edit this file with a text editor such as NotePad '''never use a word processor''' to do this because they add extra formatting characters.
'''.htaccess''' files are simple ASCII files that easily extend the Apache configuration file. Edit these files only with a text editor such as Notepad. '''Never use a word processor''' to do this because it will add extra formatting characters.


This section provides a detailed description of some commands you can use in this file a more concise and quick reference guide can be found on this [[HT | page HT]].
This section provides a detailed description of some commands you can use in this file. A more concise and quick reference guide can be found on this [[HT | page HT]].  


== What's in a name ==
== What's in a name ==
In Unix, files beginning with a period ( . ) typically hold settings for programs. These are referred to as '''dot files'''. Apache is a Unix application ported to Windows and for compatibility retains this naming convention. For all Windows users the file '''.htaccess''' is just a '''file'''; at first it looks strange but that's its full name. It has nothing before the dot, so Windows Explorer cannot create this type of file name.
In Unix, files beginning with a period ( . ) typically hold settings for programs. These are referred to as '''dot files'''. Apache is a Unix application ported to Windows and for compatibility retains this naming convention. For all Windows users the file '''.htaccess''' is just a file; at first it looks strange but that's its full name. It has nothing before the dot, so Windows Explorer cannot create this type of file name.


== Create the file ==
== Create the file ==
The easiest way to create the '''.htaccess''' file is just to copy an exiting one into its new location and edit its content. The problem in creating a new file from scratch is that most windows text editors (Window Notepad is no exception ) will insist on adding a dot txt extension so the file looks like this .htacces.txt even trying to rename this file Windows XP insists on a file name.
The easiest way to create the '''.htaccess''' file is just to copy an existing one into its new location and edit its content. The problem in creating a new file from scratch is that most Windows text editors (Windows Notepad is no exception) will insist on adding a dot txt extension so the file looks like this .htaccess.txt . Even when trying to rename this file, Windows will insist on a "proper" file name.


'''''Note'':''' Most commands in htaccess are meant to be placed on '''single line''' only.  
'''''Note'':''' Most commands in .htaccess are meant to be placed on a '''single line''' only.  


== Several htaccess files ==
== Several .htaccess files ==
You will find several htaccess files in Uniform Server do not edit these they are part of Uniform Server's security. That said the one contained in root folder WWW is placed there for you to edit, it allows you to put your server online. You can copy this file into any folder you create within your website and edit it to meet your needs.
You will find several .htaccess files in The Uniform Server. Do not remove these as they are part of The Uniform Server's security. The file in root directory WWW controls the access to your server from the Internet and Intranet (i.e., online access). You can copy this file into any directory within your website and edit it to meet your needs.


== What it affects ==
== What it affects ==
The htaccess file affects the folder it is placed in and all sub-folders. The htaccess file located in your root folder (folder WWW) affects your website and all folders and files below it.
The .htaccess file affects the directory it is placed in and all sub-directories. The .htaccess file that's located in your root directory (WWW) affects your whole website and all directories and files below it.


You can tailor this action so it does not apply to a specific folder by copying the htaccess file to that folder and removing the htaccess commands that you do not want to be applied to this folder and it’s sub-folders.
You can tailor this action so it applies to a specific sub-directory by copying the .htaccess file to that directory and removing the .htaccess commands that you do not want to be applied to this directory and its sub-directories.


From the viewpoint of a folder or file it is the nearest htaccess file that affects it.
From the viewpoint of a directory or file, it is the hierarchically nearest .htaccess file that affects it.


== What can you do with it? ==
== What can you do with it? ==
Uniform Server places no restrictions on what can be contained in the htaccess file. Hence htaccess examples found on the Internet or from textbooks should work. I have included a few to get you started.
The Uniform Server places no restrictions on what can be contained in the .htaccess file. Since the file is interpreted by Apache, examples found on the Internet or from textbooks should work.
    
    
'''''[[#top | Top]]'''''
----
----


{|
[[Category: Apache Configuration]]
| [[Image:uc_small_logo.gif]] || [[User:Ric|Ric]]
|}
 
[[Category: UniCenter]]
[[Category: Support]]
[[Category: Troubleshooting ]]
[[Category: Application]]
[[Category: Development]]

Latest revision as of 11:06, 21 June 2013

.htaccess: Introduction | Site error documents | Prevent Directory Listing | Redirect | Preventing hot linking |

.htaccess - Apache directory-level configuration file

.htaccess files are simple ASCII files that easily extend the Apache configuration file. Edit these files only with a text editor such as Notepad. Never use a word processor to do this because it will add extra formatting characters.

This section provides a detailed description of some commands you can use in this file. A more concise and quick reference guide can be found on this page HT.

What's in a name

In Unix, files beginning with a period ( . ) typically hold settings for programs. These are referred to as dot files. Apache is a Unix application ported to Windows and for compatibility retains this naming convention. For all Windows users the file .htaccess is just a file; at first it looks strange but that's its full name. It has nothing before the dot, so Windows Explorer cannot create this type of file name.

Create the file

The easiest way to create the .htaccess file is just to copy an existing one into its new location and edit its content. The problem in creating a new file from scratch is that most Windows text editors (Windows Notepad is no exception) will insist on adding a dot txt extension so the file looks like this .htaccess.txt . Even when trying to rename this file, Windows will insist on a "proper" file name.

Note: Most commands in .htaccess are meant to be placed on a single line only.

Several .htaccess files

You will find several .htaccess files in The Uniform Server. Do not remove these as they are part of The Uniform Server's security. The file in root directory WWW controls the access to your server from the Internet and Intranet (i.e., online access). You can copy this file into any directory within your website and edit it to meet your needs.

What it affects

The .htaccess file affects the directory it is placed in and all sub-directories. The .htaccess file that's located in your root directory (WWW) affects your whole website and all directories and files below it.

You can tailor this action so it applies to a specific sub-directory by copying the .htaccess file to that directory and removing the .htaccess commands that you do not want to be applied to this directory and its sub-directories.

From the viewpoint of a directory or file, it is the hierarchically nearest .htaccess file that affects it.

What can you do with it?

The Uniform Server places no restrictions on what can be contained in the .htaccess file. Since the file is interpreted by Apache, examples found on the Internet or from textbooks should work.