Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Pages: [1]
Print
Topic: Free Hosting: .htaccess restored (password protection and custom error pages)  (Read 432 times)
« on: November 17, 2008, 12:34:59 PM »
Alex Melen Offline
President / Founder
Administrator
Addict

View Profile WWW
*****
Posts: 2,205



We have tentatively restored .htaccess functionality on free hosting. You can use the .htaccess file to password protect directories and to create custom 404 pages.

For custom error pages, you simply need to add the following command, on one line, within your htaccess file:

Code:
ErrorDocument 404 /home/freehost/t35.com/d/e/demo/404.html
or
ErrorDocument 404 http://demo.t35.com/404.html


This would cause any error code resulting in 404 to be forward to 404.html. You can name the pages anything you want (I'd recommend something that would prevent you from forgetting what the page is being used for), and you can place the error pages anywhere you want within your site, so long as they are web-accessible (through a URL).



For password protection, the first thing you will need to do is create a file called .htpasswd. In the htpasswd file, you place the username and password (which is encrypted) for those whom you want to have access.

For example, a username and password of wsabstract (and I do not recommend having the username being the same as the password), the htpasswd file would look like this:

    wsabstract:y4E7Ep8e7EYV

Notice that it is UserName first, followed by the Password. There is a handy-dandy tool available for you to easily encrypt the password into the proper encoding for use in the httpasswd file.

Create a new htaccess file and place the following code in it:

Code:
AuthUserFile /home/freehost/t35.com/d/e/demo/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic

require user wsabstract

The first line is the full server path to your htpasswd file. If you have installed scripts on your server, you should be familiar with this. Please note that this is not a URL, this is a server path. Also note that if you place this htaccess file in your root directory, it will password protect your entire site, which probably isn't your exact goal.

The second to last line require user is where you enter the username of those who you want to have access to that portion of your site. Note that using this will allow only that specific user to be able to access that directory. This applies if you had an htpasswd file that had multiple users setup in it and you wanted each one to have access to an individual directory. If you wanted the entire list of users to have access to that directory, you would replace Require user xxx with require valid-user.

The AuthName is the name of the area you want to access. It could anything, such as "EnterPassword". You can change the name of this 'realm' to whatever you want, within reason. We are using AuthType Basic because we are using basic HTTP authentication.
« Last Edit: November 17, 2008, 04:30:15 PM by Alex Melen » Logged


 
« Reply #1 on: November 19, 2008, 03:46:07 AM »
Christian271 Offline
Newbie

View Profile
*
Posts: 7



Yes!  grin I've been wanting this.
Logged
« Reply #2 on: November 21, 2008, 05:36:19 PM »
chickenmeister Offline
master of chickens
Global Moderator
Member

View Profile WWW
*****
Posts: 223



awesome!  cool
Logged

Hello world!
« Reply #3 on: November 21, 2008, 09:22:48 PM »
T35 Head Forum Administrator
dWhite Offline
Administrator
Sr. Member

View Profile WWW
*****
Posts: 343



Enjoy guys and gals. Tongue
Logged

 
Pages: [1]
Print
Jump to:  

Powered by SMF | SMF © 2006-2008, Simple Machines LLC