prime Posted January 28, 2008 Share Posted January 28, 2008 ok I know my apache is properly setup, thats not an issue I have the following in my .htaccess file Options +FollowSymLinks RewriteEngine on RewriteRule index1/d/(.*)/s/(.*)/p/(.*)/ index1.php?d=$1&s=$2&p=$3 RewriteRule index1/d/(.*)/s/(.*)/p/(.*) index1.php?d=$1&s=$2&p=$3 I'm using pagination of a mysql query which I'm trying to paginate into friendly urls, here is the php code which I'm modified to try and link to this urls //Previous Page Link if ($current_page != 1) { echo '<a href="index1.php/d/' . $viewdisplay . '/s/' . ($start - $entryview) . '/p/' . $pages . '">Previous</a>'; } //Numeric Page Links for ($i = 1; $i <= $pages; $i++){ if ($i != $current_page){ echo ' <a href="index1.php/d/' . $viewdisplay . '/s/' . (($entryview * ($i - 1))) . '/p/' . $pages . '">' . $i . '</a> '; } else { echo $i . ''; } } //Next Page Link if ($current_page != $pages) { echo '<a href="index1.php/d/' . $viewdisplay . '/s/' . ($start + $entryview) . '/p/' . $pages . '">Next</a>'; } problem is the links just arn't working it keeps bringing me back to the standard index page with longer urls the more I try to click, am I doing something wrong here? Quote Link to comment https://forums.phpfreaks.com/topic/88278-solved-php-mod-rewrite/ Share on other sites More sharing options...
prime Posted January 28, 2008 Author Share Posted January 28, 2008 here's the complete php code, I'm just not sure whats going on, from what I've read I'm pretty sure I've done this right <?php include("pagecontent.inc"); $this_file = $_SERVER['PHP_SELF']; if(isset($_GET['d']) && is_numeric ($_GET['d'])) { $viewdisplay = $_GET['d']; } else { $viewdisplay = "1"; } ?> <br/> <center> <?php if($viewdisplay == "1") { echo "<a class=\"pagelink\" target=\"_top\" href=\"$this_file?d=2\"><b class=\"alt_version\">View Characters with web sites only</b></a>"; } elseif($viewdisplay == "2") { echo "<a class=\"pagelink\" target=\"_top\" href=\"$this_file?d=1\"><b class=\"alt_version\">View All Characters Entered</b></a>"; } ?> </center> <br/><br/> <?php include("../../admin/secret admin files/verification.php") ?> <?php $connection = mysql_connect($host,$user,$password) or die("couldn't connect toserver"); $db = mysql_select_db($database,$connection) or die("couldn't select database"); if($viewdisplay == "1") { $query= "Select * from registry order by name"; } elseif($viewdisplay == "2") { $query= "Select * from registry where url != '' order by name"; } $result = mysql_query($query) or die("couldn't execute query"); $num = mysql_num_rows($result); if($viewdisplay == "1") { $entryview = "20"; } elseif($viewdisplay == "2") { $entryview = "8"; } if(isset($_GET['p']) && is_numeric ($_GET['p'])) { $pages = $_GET['p']; } else { if($num > $entryview) { $pages = ceil ($num/$entryview); } else { $pages = "1"; } } if(isset($_GET['s']) && is_numeric ($_GET['s'])) { $start = $_GET['s']; } else { $start = "0"; } if($viewdisplay == "1") { echo "<center><font color=\"orange\">There are currently $num people registered</font></center>"; } elseif($viewdisplay == "2") { echo "<center><font color=\"orange\">There are currently $num people with registered websites</font></center>"; } ?> <?php if($viewdisplay == "1") { $query= "Select * from registry order by name LIMIT $start, $entryview"; } elseif($viewdisplay == "2") { $query= "Select * from registry where url != '' order by name LIMIT $start, $entryview"; } $result = mysql_query($query) or die("couldn't execute query"); echo "<center><font color=\"orange\">"; if ($pages > 1) { echo "<br /><p>"; $current_page = ($start/$entryview) + 1; } //Previous Page Link if ($current_page != 1) { echo '<a href="' . $this_file . '/d/' . $viewdisplay . '/s/' . ($start - $entryview) . '/p/' . $pages . '">Previous</a>'; } //Numeric Page Links for ($i = 1; $i <= $pages; $i++){ if ($i != $current_page){ echo ' <a href="' . $this_file . '/d/' . $viewdisplay . '/s/' . (($entryview * ($i - 1))) . '/p/' . $pages . '">' . $i . '</a> '; } else { echo $i . ''; } } //Next Page Link if ($current_page != $pages) { echo '<a href="' . $this_file . '/d/' . $viewdisplay . '/s/' . ($start + $entryview) . '/p/' . $pages . '">Next</a>'; } echo "</font></center>"; echo "<table class='fore' border='1' bordercolor='white' width='100%' align='center'>"; echo "<tr> <td><center><b class='table_headers'>Character name</b></center></td> <td><center><b class='table_headers'>Character Site/Blog URL</b></center></td> <td><center><b class='table_headers'>Player's Comments</b></center></td> </tr>"; while ($row = mysql_fetch_array($result)) { extract($row); $cname = ucfirst(strtolower($name)); echo "<tr>\n <td width='150' valign='top'><b class='rname'><a class='mainmenu' href='http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1=$cname'>$cname</a></b></td>\n <td width='200' valign='top'>"; if ($url == null) { echo "<b class='rnolink'>No website submitted</b>"; } elseif ($url == "banned") { echo "<b class='rlinkban'><b><center>Url has been removed due to breach of Runescape rules</center></b>"; } else { echo "<a class='mainmenu' href='$url' target='_new'><b class='rname'>$cname's website</b>"; } echo "</b></a></td>\n <td width='*' valign='top'><b class='tdes'>"; if ($description == null) { echo "<b class='rnodesc'>No comment</b>"; } else { echo "<b class='rdesc'>$description</b>"; } echo "</b></td>\n </tr>\n"; echo "<tr><td colspan='3'></td></tr>\n"; } echo "</table>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/88278-solved-php-mod-rewrite/#findComment-451747 Share on other sites More sharing options...
prime Posted January 28, 2008 Author Share Posted January 28, 2008 Dang wish I could edit longer rather than making new posts anyhow I've trying to figure this out, I think the problem is getting the get information from the modified urls, but I have no idea how to get around this, I'm probably over complicating something but I'm not sure what Quote Link to comment https://forums.phpfreaks.com/topic/88278-solved-php-mod-rewrite/#findComment-451760 Share on other sites More sharing options...
prime Posted January 29, 2008 Author Share Posted January 29, 2008 yeeehaw the problem is solved I found the problem it was in the .htaccess file it should of been Options +FollowSymLinks RewriteEngine on RewriteRule index1.php/d/(.*)/s/(.*)/p/(.*)/ index1.php?d=$1&s=$2&p=$3 RewriteRule index1.php/d/(.*)/s/(.*)/p/(.*) index1.php?d=$1&s=$2&p=$3 I do have one firth question this creates urls like http://www.example.com/sections/registry/index1.php/d/2/s/0/p/6 is there anyway to actually this appear like say http://www.example.com/sections/registry/d/2/s/0/p/6/index.html or something similar? Quote Link to comment https://forums.phpfreaks.com/topic/88278-solved-php-mod-rewrite/#findComment-451833 Share on other sites More sharing options...
prime Posted January 29, 2008 Author Share Posted January 29, 2008 Ok nvm I finaly worked it out Options +FollowSymLinks RewriteEngine on RewriteRule d/(.*)/s/(.*)/p/(.*)/registry.html/ index.php?&d=$1&s=$2&p=$3 RewriteRule d/(.*)/s/(.*)/p/(.*)/registry.html index.php?&d=$1&s=$2&p=$3 alls cool its working good Quote Link to comment https://forums.phpfreaks.com/topic/88278-solved-php-mod-rewrite/#findComment-451931 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.