Click to See Complete Forum and Search --> : .htaccess ?
neotrace
05-19-2001, 12:53 AM
currently when a client wants to connect to a page, there is an htaccess file in the dir. of the file they need to access prompting for a password. How could i make one passwd. entry box that would take them to the appriate page depending on the user name and pass???
11000
05-19-2001, 05:27 PM
Well, I'm pretty sure you'll need some kind of a programming/scripting language to do this. I haven't tried it with .htaccess but I think that the method that I've used will work. I've used php which has built in HTTP authentication variables that will keep track of the user name and password . You can then access it with a php script and redirect it based on the user name. Of course, this method requires PHP to be installed on the server as a module. If you are curious I could post the script I wrote.
Other languages such as perl may be able to do the same thing.
neotrace
05-19-2001, 11:56 PM
yes please send me this script and info on the module for apache that i would need, i'm running redhat 7.1.
11000
05-20-2001, 12:33 AM
Here is an extremely simplified version of the script. It has the important features. This file would be saved as index.php, and apache set up to look for that file first. Then what you'd do is if a user's name was "bob" then you'd make a page called bob.html in the .htaccess protected directory. The $location variable is set to bob.html in the first part of the script and that is then sent to the header in the second part which redirects the browser.
<?php
$location = "$PHP_AUTH_USER.html";
header("Location: $location");
exit;
?>
You can do a lot more with it. The version I have running is a little more complicated since I have 70+ users and not all of them go to their own page. :) If statements and such thing come into play then. Let me know if any of this doesn't make any sense! :)
Also, as far as install PHP as a module, it simply means don't install the cgi version. Which most people don't, but I wanted to add the disclaimer. There's a NHF on installing PHP with Apache here. (http://www.linuxnewbie.org/nhf/intel/webserving/php_apache.html)
Further disclaimer: Like I said in the first post I havn't tried this with .htaccess, but if it happens not to work there's ways to do authentication with php, and a little research.
Hope that helps.
neotrace
05-20-2001, 01:36 AM
so say i have three users: bob, steve, and korey. When the client hit's the index.php page it will prompt for a pass. then how would i make multiple user entry's so that when bob, steve, or korey enter there user and pass it will take them to either korey.htm, bob.htm, or steve.htm.
<?php
$location = "$PHP_AUTH_USER.html";
header("Location: $korey.htm");
exit;
?>
It's not important to incorporate this w/.htaccess, right now i'm just using .htaccess as a temp fix.
Thanks aton for the info, by the way would u have any knowledge of dns and/or sendmail???
11000
05-20-2001, 04:04 PM
Ok, you'll probably want to learn a little php before you delve too far into this. The code snippet I gave you doesn't do any actual authentication, it just takes the user name the user entered when prompted by .htaccess and puts it in the $PHP_AUTH_USER variable. You'll have to do a little research if you want PHP to do the authentication.
The $location = "$PHP_AUTH_USERS.html"; part of the script is the part of the script that changes the $location variable to whatever the users name is, followed by .html. So if user Korey is logging in then you are setting $location to korey.html. So at this point $PHP_AUTH_USER = korey
$location = "$PHP_AUTH_USER.html";
[code/]
The next part then changes the header location to whatever is in the $location variable, in this case korey.html.
[code] header("Location: $location");
exit;
?>
I havn't really worked with sendmail or DNS much at all, so no, I don't know much about them.
neotrace
05-20-2001, 04:34 PM
well this is becoming beyond me, first i've got to get my linux box working first, then it's off to barnes & noble.
thankx for the help
micxz
05-21-2001, 02:34 AM
I would be willing to help you solve this problem. If you have php installed on your server. The code offered above will work great if setup correctly. Send me an email if you want some more code and how to use it?
feeling good today,
micxz
neotrace
05-21-2001, 02:51 AM
please send some sample code so i may determine whether php is working correct on my apache web server
webbcite
05-21-2001, 11:52 AM
Just put <? phpinfo(); ?>
On any page named something.php3 (if you have PHP3 installed) or something.php (if you have PHP4 installed).
This will give you a list of the PHP configuration settings for you server. If you see this, then you have it installed correctly. If you do not, then you will just see:
<? phpinfo(); ?>
And you will need to install PHP.
Scott
neotrace
05-21-2001, 02:46 PM
well i believe i installed php wrong, when i go to the page nothing comes up but a blank screen
neotrace
05-23-2001, 01:11 AM
i believe the problem w/my php install may be in the web server?
11000
05-24-2001, 12:13 AM
Originally posted by neotrace0:
<STRONG>well i believe i installed php wrong, when i go to the page nothing comes up but a blank screen</STRONG>
How are you accessing the page? Through the web server? By using http://localhost or http://127.0.0.1
neotrace
05-24-2001, 09:49 AM
actually i was accessing the server from another computer on my internal network, 192.168.0.1. I believe the problem may be in the instructions I followed to install php. The server doesn't bomb when it displays the page, it just displays a blank page, LOL. Though i've found a new set of install instructions that seem much more detailed and should give better results Fonund Here (http://www.linuxnewbie.org/nhf/intel/webserving/a_m_f1.html)
neotrace
05-28-2001, 12:13 AM
ok i have apache, php4, and sqlserver working together, now i need a script that when a user goes to a page say, auth.htm they are prompted to enter a password, than according to their user :pass they will be taken to /home/korey/index.htm, /home/bob/index.htm, or /chas/index.htm