Jump to content

php/html/mysql rewritecond and rewriterule need help thank you..


redarrow

Recommended Posts

Advance thank you....

 

I am trying to use mod_rewite and mysql all together....

 

my current logic is i have setup .htaccess to get the ip from a seprate page

does it look correct to you cheers.......

 

If the ip is from ip_address using rewritecond they are sent to ban.html

 

IF MY EXAMPLE IS INCORRECT PLEASE HELP ME THANK YOU......

 

 

ip_address.php

<?php

//database connection

$sql="SELECT * from ban_ip_address";

$res=mysql_query($query)or die(mysql_error());

while($x=mysql_fetch_assoc($res)){

$x['ip_address'];
}

?>

 

 

ban.html

<html>
<head>
<title>
ban users
</title>
</head>
<body>
<h1><b>YOU ARE BAN FROM HERE GO AWAY</b></h1>
</body>
</html>

 

 

.htaccess


Options+FollowSymLinks
Options+Indexes
RewriteEngine On

RewriteCond % {REMOTE_ADDR}
RewriteCond %{SCRIPT_FILENAME}  !-f
RewriteRule ^(.*)ip_address.php !-f
RewriteRule ^(.*) ban.html[r]
RewriteRule ^([a-z]+)(.*)cookers\.html$ index.php?id=$i[NC,L]

 

Why are you using mod_rewrite at all.  Create a file on your server called checkban.php, which contains:

 

<?php
// database connection

$sql = "SELECT * from ban_ip_address WHERE ip='" . mysql_real_escape_string($_SERVER['REMOTE_ADDR']) . "'";
$res = mysql_query($query)or die(mysql_error());

if (mysql_num_rows($res))
{
     header('Location: ban.html');
}
?>

Then include it on any page which should have ban enforcement.

What do you mean by "that old to you"...?  Using mod_rewrite for this purpose really makes no sense.  You don't mod_rewrite based on the results of a script, you mod_rewrite to take a URL that a user enters/locates to on the browser, and translate it to the path of the file on your server that you want to execute or return.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.