B2B Articles - April 26, 2010
You can make configuration changes on a per-directory basis by creating .htaccess files on an Apache server (although other server options do exist). The directives that you create within the .htaccess file will control the directory the file is placed within--place the file at the root level of the directory.
How to create an .htaccess file:
Like most any file type, you can create a file by renaming a simple text document and giving it the name ".access". However, Windows users may need to make changes to be able to view .htaccess files within their system, which is a simple configuration change to allow viewing of "hidden files." Dreamweaver may not recognize .htaccess files due to the fact that they are an unrecognized file extension by default. If you use Dreamweaver or a similar program to edit code, select to "open the file using Dreamweaver." Two programs that are great for editing .htaccess files are: NotePad or SimpleText. By default, Notepad it will save the file .htaccess.txt--so you will need to remove the .txt extension.
Note: .htaccess is the file extension. It is not file.htaccess or somepage.htaccess, it is just named .htaccess
General notes on .htaccess
Use .htaccess to password protect a directory
You can use .htaccess to password a directory on your server. There are numerous approaches to creating an authentication system. Htaccess can be used for passwords. Place the username and password in the htpasswd file.
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Directory To Be Protected"
Require valid-user
The full/path/to/.htpasswd should be the full path to the .htpasswd file. On Windows for instance, it could look like this: C:\wwwrootlevel\username\.htpasswd.
The above .htaccess file will password protect all files in the folder that it is placed in, including all sub-folders as well.
Use .htaccess to protect a single file
AuthUserFile /full/path/to/.htpasswd
AuthType Basic
AuthName "My Secret Page"
<Files "mywebfile.html">
Require valid-user
</Files>
This script will password-protect just the mywebfile.html file in the folder where you put the .htaccess file.
Change your default directory page
You can specify a certain file to be your index file (directory index). By default, index.html or index.htm is often the default index for directories. Let's say you wanted to use a different file as your directory index, you could by using .htaccess to specify the file.
DirectoryIndex filename.html
Redirects using .htaccess
You can create redirects using .htaccess as well. For example, 301 permanent redirects are very important for SEO purposes since they let Google and other search engines know if a file has been moved and where to find this file.
Redirect /olddirectory/oldfile.html https://yoursite.com/newdirectory/newfile.html
Tel 212-993-7809
Ironpaper ®
10 East 33rd Street
6th Floor
New York, NY 10016
Map
New York Agency
B2B marketing
B2B Content
Demand generation agency
Digital Marketing
Account-Based Marketing
ABM for SaaS
ABM for energy
Demand generation campaigns
Industry marketing
Privacy Policy
First-party data marketing
SaaS marketing
SEO for B2B
IoT Marketing
B2B Marketing for IoT Companies
HubSpot Agency
B2B Product Marketing
B2B Software Marketing
IoT go-to-market strategy
IT Marketing
HubSpot for ABM
ABM for AI companies
Technology Marketing
Marketing for IT Companies
ABM Campaigns
B2B lead generation
B2B Marketing and Growth Agency.
Grow your B2B business boldly. Ironpaper is a B2B marketing agency. We build growth engines for marketing and sales success. We drive demand generation campaigns, ABM programs, B2B content, sales enablement, qualified leads, and B2B marketing efforts.