Forum Moderators: phranque

Message Too Old, No Replies

URL hiding/masking in address bar using .htaccess

URL masking

         

anjaan79

6:47 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



Hello,

I am looking for the following. If someone can help that would be great:

I am running a URL redirection script (freeware) which works like this -
[mydomain.com...] --> [mydomain.com...]

However, this script does not mask the URL so the address bar shows the actual URL [mydomain.com...]

How can I hide the actual file name in the browser address bar?

I have control over the source file names in videoz folder, for example, I can name it whatever I want /?1, /?AGD, /?34 etc. But I do not have control over destination file names (However it will always be alphanumeric: 45g3.html, 64j3.html, 34fg.html etc.) And the reason I don't have control over that is because there is another script being used which generates those files.

I will be creating hundreds of redirection links using the URL redirection script so is it possible to hide the actual file name using .htaccess? I do not care what's displayed in the browser address bar as long as it's not the actual file name.

Thanks for reading and I look forward to your suggestions.

g1smd

7:17 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Change your rule so that it is a rewrite instead of a redirect.

If you're doing this in PHP, you are going to have to change it to be in your .htaccess file instead.

anjaan79

7:34 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



The problem is that I am using a redirection script not made by me...it's freeware from "notpublic"

[edited by: jdMorgan at 2:45 am (utc) on Mar. 31, 2009]
[edit reason] No URLs, Please. See TOS. [/edit]

anjaan79

7:42 pm on Mar 30, 2009 (gmt 0)

10+ Year Member



Actually here is the redirection portion of the script. Do you know how it can be edited so that the final URL does not show up in the address bar?


$get_id = $_SERVER['QUERY_STRING'];
if ($get_id == "") {

// Include Your HTML webpage if You got one
/* E D I T T H E L I N E B E L O W I F Y O U N E E D T O */

$mainfile = "main.htm";

if (file_exists($mainfile)) {
include $mainfile;
}
} else {
if(!file_exists('config.php')) {
echo 'The file config.php is corrupt or missing!';
exit;
}
require('config.php');
$get_id = $_SERVER['QUERY_STRING'];
function hideurl_error($error){
echo $error; }
if($get_id){
$DBConn = mysql_connect($Database_Host, $Database_Username, $Database_Password) or die(hideurl_error("Could not connect to database server. Check your settings."));
$DB_DB = mysql_select_db($Database_Name, $DBConn) or die(hideurl_error("Could not connect to database ($Database_Name). Perhaps you don't have the right permissions on this DB. Check your settings"));
$sql = mysql_query("SELECT link_url,link_date,link_last FROM hideurl WHERE link_code='$get_id'");
$site_arr = mysql_fetch_array($sql);
$todaynumber = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
$site_redirect = $site_arr['link_url'];
$expiry = $site_arr['link_date'];

if(($expiry <= $todaynumber) ¦¦ (!$site_arr )) {
$sqlcfg = mysql_query("SELECT cfg_notfound FROM hideurl_conf WHERE cfg_id='1'");
$nosite = mysql_fetch_array($sqlcfg);
$Not_Found = $nosite['cfg_notfound'];
header("Location: $Not_Found");
}
if(($expiry > $todaynumber) && ($site_arr )){
mysql_query("UPDATE hideurl SET link_count = link_count + 1 WHERE link_code='$get_id'");
mysql_query("UPDATE hideurl SET link_last = $todaynumber WHERE link_code='$get_id'");
header("Location: $site_redirect");
}
}
}

g1smd

7:53 pm on Mar 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It can't. As I stated above, you need to set up a rewrite in your .htaccess file in place of this redirect in your PHP file.

jdMorgan

2:48 am on Mar 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Whatever you link to shows up in the address bar. If it were otherwise, Web exploits would run ranpant, and the internet would have died years ago. So, if you want a particular URL to show in the address bar, then link to that URL. That is the only way.

Once that URL is requested from your server, mod_rewrite can intercept it and send the request to any internal filepath you like.

Jim