[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Best way to make a redirect link?

Posted on 2005-04-05
7
Medium Priority
?
219 Views
Last Modified: 2010-04-06
Hi,

Would anyone know the best way to make a redirect link? I need to redirect quite a few links, basically I need to mask where a link goes to, so I guess it would need to be done with php or something. Here is the situation, on my site, users can get reports of their activity on the site, the problem is the link for their report shows the doc directory. It wouldn't take much trial and error for people to find a way of accessing other users docs. The docs are downloadable so I just need a way to mask the destination.

Does anyone know the best way to achieve this? Bearing in mind that the links are generated daily? I know I am probably fishing here so I would accept either some direct suggestions on how to do it or maybe links to redirect scripts or something?

Thanks for your time.

Oh, the site uses a mysql database and runs on an apache server.

Thanks
Jon
0
Comment
Question by:jalexan123
5 Comments
 
LVL 15

Accepted Solution

by:
mish33 earned 500 total points
ID: 13713045
use mod_rewrite (http://httpd.apache.org/docs-2.0/misc/rewriteguide.html)
to redirect from /usename/report.dat to /doc/day/username.dat
and
mod_auth to restrict user to /username only.
0
 
LVL 5

Assisted Solution

by:jericotolentino
jericotolentino earned 500 total points
ID: 13714291
Hi,

You can probably have a field in your MySQL database that contains links. Then just get it using mysql_query. So you'll have something that looks like this...

<?
...some code here...
$result = mysql_query($sql);

while ($row=mysql_fetch_array($result)) {
$link = $row['link'];
...your other fields...

}

?>

<html>
<head>
<title>My page</title>
<script type="text/javascript">
window.location="<? echo $link; ?>";
</script>
</head>
...the rest of the page...
0
 
LVL 16

Assisted Solution

by:alain34
alain34 earned 500 total points
ID: 13714531
Redirect in php

<?php
header("Location: http://www.example.com/"); /* Redirect browser */
?>
0
 
LVL 6

Assisted Solution

by:alextr2003fr
alextr2003fr earned 500 total points
ID: 13715961
<?php
if (!empty($_GET['linkid']))
{
        $linkid = $_GET['linkid'];
        //now you can treat your links useing any kind of test you want
        //for example from a database like $page = GetPageFromMySQLById($linkid) and write your
        //function to get it from the db
        //then do a: include $page;
        //a simple test here :
        if ($linkid == 1) {
                include 'path/to/your/page.php'; //will actually include the page without showing its path
        }
}

// To test try to show your page with usieing for example something like page.php?linkid=1
?>
0
 

Author Comment

by:jalexan123
ID: 13716037
Hi,

Sorry I have't been in contact since posting this question. I will give those tries a go and get back to you.

Thanks
Jon
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question