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]

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.