redarrow Posted February 25, 2008 Share Posted February 25, 2008 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 https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/ Share on other sites More sharing options...
mainewoods Posted February 25, 2008 Share Posted February 25, 2008 your statement in the loop doesn't do anything! while($x=mysql_fetch_assoc($res)){ $x['ip_address']; } Link to comment https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475511 Share on other sites More sharing options...
redarrow Posted February 25, 2008 Author Share Posted February 25, 2008 modrewite is reading that file to get the ip address i need to no how modrewite does that... please help Link to comment https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475513 Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 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 https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475525 Share on other sites More sharing options...
redarrow Posted February 25, 2008 Author Share Posted February 25, 2008 becouse that old to me sorry... Link to comment https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475533 Share on other sites More sharing options...
Bauer418 Posted February 25, 2008 Share Posted February 25, 2008 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 https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475557 Share on other sites More sharing options...
dave420 Posted February 25, 2008 Share Posted February 25, 2008 Well, you can use mod_rewrite for that, though these days it's usually a better idea to do it in code instead. Link to comment https://forums.phpfreaks.com/topic/92822-phphtmlmysql-rewritecond-and-rewriterule-need-help-thank-you/#findComment-475681 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.