FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


.htaccess help





AOP Web Development
Hi, i would like to ask for some experts here about the htaccess actually i'm about to create a script that every user visit will redirect first to a page and if everything works then proceed to the next page.
anyway nothing to bother that.

Now this is what i want. i want all links when users click. i want all to pass first to check.php to process some background script. if everything ok then it will redirect back to the link they click.

ex. the user click going to contactus.php but it need to bypass to check.php and then proceed to contactus.php


Other thing is how do detect if the next page is being post or get? detecting by REQUEST_METHOD in htaccess... coz if the user submit some form then it will not suppose to bypass to check.php but it goes directly to the action target page..


Hope you can help thanks
Peterssidan
I don't get exactly how you mean but it sounds like you not should use .htaccess for this. Using .htaccess you can't be that dynamic as far as I know. I think you should use the header function i php.

This PHP code will redirect the user to http://www.adrinponce.com/check.php :
Code:
header('Location: http://www.adrinponce.com/check.php');
rvec
if the user should only be redirected to check.php once you can use a session. Set it at the end of check.php and as long as it's not set use the header function to redirect them to check.php .

If a user should be send to check.php before each request you can unset the session var at the end of each script. Another session var could then be the page where the user should be redirected.

An example of the code you could use in index.php:
Code:
<?php
session_start();
if ($_SESSION['check'] != 1) {
    $_SESSION['redirect'] = "index.php"; //relative link from check.php to the current file
    header('Location:check.php'); //relative link from current file to check.php
} else {


    your code here


    $_SESSION['check'] = 0;
}


And the code in check.php:
Code:
<?php
session_start();
if ($_SESSION['check'] != 1) {


    your code here


    $_SESSION['check'] = 1
    header("Location:{$_SESSION['redirect']}");
}
AOP Web Development
Thank to all who replied and for your effort, anyway this is what i want.

let say. there is a link of www.example1.com/index.php from referersite.com once the it click it will redirect to cloak the user. before it proceed to the exact page.

ex.
you visit example1.com/category/index.php, then it will redirect first to cloak.php before proceeding to the exact link location. so the main thing here is any links from the site will pass thru cloak.php to check before it will proceed to the main page.
rvec
AOP Web Development wrote:
Thank to all who replied and for your effort, anyway this is what i want.

let say. there is a link of www.example1.com/index.php from referersite.com once the it click it will redirect to cloak the user. before it proceed to the exact page.

ex.
you visit example1.com/category/index.php, then it will redirect first to cloak.php before proceeding to the exact link location. so the main thing here is any links from the site will pass thru cloak.php to check before it will proceed to the main page.

If you want to let the user go through the cloak.php every time he opens a page the above script will do that. If you want to let the user go to the cloak.php page only once a session you can use this script:

Code:
<?php
session_start();
if ($_SESSION['check'] != 1) {
    $_SESSION['redirect'] = "index.php"; //relative link from check.php to the current file
    header('Location:cloak.php'); //relative link from current file to cloak.php
} else {


    your code here


    //$_SESSION['check'] = 0;
}


And the code in check.php:
Code:
<?php
session_start();
if ($_SESSION['check'] != 1) {


    your code here


    $_SESSION['check'] = 1
    header("Location:{$_SESSION['redirect']}");
}
AOP Web Development
yes, got your point, but that does it mean that i have put that code in all the pages i will create? or?
coz this thing is something like a background script to trigger the users visit on a specific site.

so if what every links on that certain domain. shall trigger on the cloak.

so if i have inbound links on the example1.com or any links inside the domain should be trigger first atleast once in the cloaker script.
rvec
i have no idea how you could do something like that in a htaccess file, but I think what you want is possible in htaccess. If it isn't you have to add this code to every page which should redirect to the cloak.php file.
AOP Web Development
thanks for your thought, anyway i got an basic idea about what you've done, but instead of setting in a session i set it into cookie, as htaccess had also check if the cookie name i assigned had been set.
Related topics
htaccess Password Protection
.htaccess tutorial
[tutor] How to protect images without htaccess using PHP
Custom error pages using .htaccess
.htaccess problem
Need help with htaccess
.htaccess again
[HELP]redireccion de subdominios por medio de .htaccess
Help please,"Forbidden You don't have permission to acc
question about .htaccess mod_python with publisher mod
.htaccess Problem With Register_Globals
secure subdomain .htaccess problem.
.htaccess Problem - PLEASE help - Reward Offered
Yahoo Hosting Doesn't Support .HTACCESS. Help me
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.