Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 117,270 PHP Programmers for FREE! Ask your question and get quick answers from experts. There are 1,782 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Problem with re-directing.

 
Reply to this topicStart new topic

Problem with re-directing.

0day
post 10 May, 2008 - 10:56 AM
Post #1


New D.I.C Head

*
Joined: 10 May, 2008
Posts: 3

Recently on my mostly PHP website, that I just started. I added a .htaccess and .htpassword. I set a password and User name, and went to my site to test it out.

That is when I started having problems. After I logged in I would be continuously re-directed to a "Kwikiphp.com web hosting blog" and was unable to access my actual website.

So, I went back and deleted my .htaccess and .htpasswd file and went to my website, everything is back to normal now.

Does anybody know a fix for this? I want to keep the files I deleted and have a Username/Password to access my website.

Update: Here is my .htaccess code.

CODE

RewriteEngine On

RewriteRule ^(.*).flv$ index.php?q=$1&flv=1

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/vol1/myok_1830809/htdocs/.htpasswd/
AuthGroupFile /dev/null
require valid-user

## SITE REFERRER BANNING
RewriteEngine on
# Options +FollowSymlinks

RewriteCond %{HTTP_REFERER} www\.google\.com [NC,OR]
RewriteCond %{HTTP_REFERER} www\.websense\.com [NC]
RewriteRule .* - [F]

## PREVENT VIEWING OF .HTACCESS
<Files .htaccess>
order allow,deny
deny from all
</Files>


** Edit ** code.gif

This post has been edited by no2pencil: 10 May, 2008 - 09:17 PM
User is offlineProfile CardPM

Go to the top of the page


no2pencil
post 11 May, 2008 - 01:54 AM
Post #2


Wet D.I.C.

Group Icon
Joined: 10 May, 2007
Posts: 5,406



Thanked 35 times

Dream Kudos: 2325

Expert In: Goofing Off

My Contributions


QUOTE(0day @ 10 May, 2008 - 01:56 PM) *

After I logged in I would be continuously re-directed to a "Kwikiphp.com web hosting blog" and was unable to access my actual website.

So, I went back and deleted my .htaccess and .htpasswd file and went to my website, everything is back to normal now.

Does anybody know a fix for this? I want to keep the files I deleted and have a Username/Password to access my website.

You can run a check to see if the user is currently signed in. If not, create a login function in an include file, & load that content. Maybe something like a user id & password input box.

Once the user logs in, create a cookie with the users username. Then, at the header of each php file, check for that cookie. If they are signed in, load the content. If you cannot find the cookie, load the login page.
User is online!Profile CardPM

Go to the top of the page

0day
post 11 May, 2008 - 04:07 PM
Post #3


New D.I.C Head

*
Joined: 10 May, 2008
Posts: 3

Would you be willing to please explain how exactly do I do that?
User is offlineProfile CardPM

Go to the top of the page

joeyadms
post 12 May, 2008 - 01:06 AM
Post #4


D.I.C Head

Group Icon
Joined: 4 May, 2008
Posts: 145



Thanked 6 times

Dream Kudos: 600
My Contributions


Have a look at some pseudo-code, and give it a try.

CODE

//Login.php
session_start();
$username = $_POST['username'];
$password = $_POST['password'];
if(username and password are valid) {
$_SESSION['isAuthed'] = true;
$_SESSION['username'] = $username;
header("Location: http://www.site.com/");
} else {
// Show login form
}


Now on your main site, on your php pages at the top
CODE

session_start();
if(!$_SESSION['isAuthed']){
header("Location:http://www.site.com/login.php");
}



But I think your problem is here
CODE

AuthUserFile /home/vol1/myok_1830809/htdocs/.htpasswd/


should be
CODE

AuthUserFile /home/vol1/myok_1830809/htdocs/.htpasswd


Also I would take .htpasswd out of web root, even tho you have a rule for it.

User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/6/08 10:20PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month