Jump to content

Trying to move across to SEO URL's


-Karl-

Recommended Posts

Here's my PHP code:

                      <div id="contenttitle">Quests</div>
                        <div id="news">
<?php
    

function questview($id) {

require_once ('includes/connect.php');//connect to db
include ('includes/steps.php');
/* query for item */
    $query = "SELECT * FROM quest WHERE id=$id";
    $result = mysql_query ($query);
    
    /* if we get no results back, error out */
$numrtn = mysql_num_rows($result);

    if ($numrtn == 0) {
        echo "The quest guide requested cannot be found\n";
        echo $id;
        return;
    }
    $row = mysql_fetch_assoc($result);
    /* easier to read variables and 
     * striping out tags */
    $id = $row['id'];
    $name = $row['name'];
    $contributors = $row['contributors'];
    $guideby = $row['guideby'];
    $added = $row['added'];
    $location = $row['startinglocation'];
    $members = $row['members'];
    $description = $row['description'];
    $difficulty = $row['difficulty'];
    $requirements = $row['requirements'];
    $items = $row['items'];
    $reward = $row['reward'];
    $guide = $row['mainbody'];
    $length = $row['length'];
    $updated = $row['updated'];
    if ($members == "Y") {
        $mem = "members only quest</b>, so it can only be done on a <b>members</b> server.";
    }else{
        $mem = "non-members quest</b>.";
    }
    if ($updated == 0){
    $up = 'No-one has updated this quest guide';    
    }else{    
    $date2 = date("l jS F Y @ H:i:s ", $updated);
    $up = 'It was last updated on '.$date2;
    }
    if ($contributors != ""){
    $con = 'Thanks also to <b>'.$contributors.'</b> for changes.';    
    }else{
    $con = 'No-one else has contributed to this quest guide.';
    }
    //$date = date("D M jS, Y g:i a", $added);
    $date = date("l jS F Y @ H:i:s ", $added);
    
echo '
<div id="quest"><table width="100%" border="0">
  <tr>
    <td>
        <h1 align="center">'.$name.'</h1>
';
echo step_js();
echo pick_clue($id);
echo toggle_reward();
echo toggle_clue();
echo '<br>';
echo '
<p class="text1">This quest guide was written by <b>'.$guideby.'</b> for use on Runehints and entered into the database on '.$date.'. '.$up.'. '.$con.'  <br /></p>
<p><span class="text1"><br />This quest is <b>'.$mem.'</span></p>
<p>
<span class="qtitle">Description: </span><span class="text1">'.$description.'</span></p>
<p><span class="qtitle">Difficulty Level: </span><span class="text1">'.$difficulty.'</span></p>
<p>
<span class="qtitle">Requirements: </span><span class="text1">'.$requirements.'</span></p>

<p>
<span class="qtitle">Items Needed During Quest: </span><span class="text1">'.$items.'</span></p>
<p>
<span class="qtitle">Starting Location: </span><span class="text1">'.$location.'</span></p>
  <p><span class="qtitles">Quest Instructions:</span></p>';
  echo list_steps($id, true);
echo '<p>
<div id="rewardwrap" style="display:none;"><span class="qtitle">Reward: </span><span class="text1">'.$reward.'</span></div></p>
   </td>
  </tr>
</table></div> ';
}

function selectquest(){
    require_once ('includes/connect.php');//connect to db

    $result = mysql_query("SELECT * FROM quest");
    $num_rows = mysql_num_rows($result);
    echo 'FREE QUEST GUIDES';
            
              /* query for quests */
        $n_query = "SELECT id, name, difficulty, members, sorter FROM quest WHERE members='n' ORDER BY sorter ASC";
    
        $n_result = mysql_query ($n_query);
        while ($n_row = mysql_fetch_assoc($n_result)) {
        $n_name = $n_row['name'];  
        //$n_guideby = $n_row['guideby'];
        $n_difficulty = $n_row['difficulty'];
        $id = $n_row['id'];
        /* place table row data in 
         * easier to use variables.
         * & display the data */
         $f_name = str_replace(' ', '_', $n_name);
              
       echo '<p><a href="quests-'.$f_name.'-'.$id.'.html"><b>'.$n_name.'</b></a>'.$n_difficulty.'</p>'; 
    }
        /* finish up table*/
    echo 'MEMBER QUEST GUIDES';

    /* query for quests */
        $y_query = "SELECT id, name, difficulty, members, sorter FROM quest WHERE members='y' ORDER BY sorter ASC";
        $y_result = mysql_query ($y_query);
        while ($y_row = mysql_fetch_assoc($y_result)) {
        $y_name = $y_row['name'];  
        //$y_guideby = $y_row['guideby'];
        $y_difficulty = $y_row['difficulty'];
        $yid = $y_row['id'];

        /* place table row data in 
         * easier to use variables.
         * & display the data */

        echo '<p><a href="quest.php?flibble=questview&id='.$yid.'&ic=1"><b>'.$y_name.'</b></a>'.$y_difficulty.'</p>'; 
        }

        /* finish up table*/
    }
    
    
    switch($_GET['flibble']) {
    
    case 'selectquest':
        selectquest();
        break;
    case 'questview':
        questview($_GET['id']);
        break;        
    default:
        selectquest();
}
    
?> 
                        </div>

 

Here's my RewriteRule:

RewriteRule ^quests-(.*)-([0-9])/.html$  /quests.php?flibble=questview&id=$2&ic=1

 

I didn't write the original PHP code, so this is turning out to be annoying.

 

Any help to point me in the correct direction is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/207138-trying-to-move-across-to-seo-urls/
Share on other sites

Options +FollowSymlinks

RewriteEngine on

RewriteRule ^blog/([0-9]+)-([a-z]+) http://corz.org/blog/index.php?archive=$1-$2 [NC]

 

That'll change.. http://corz.org/blog/index.php?archive=1-4, to http://corz.org/blog/1-4

So what you could do is change that..

for example..

Options +FollowSymlinks

RewriteEngine on

RewriteRule ^quests-([0-9][a-z][A-Z]+)-([0-9][a-z][A-Z]+).html /quests.php?flibible=$1&id=$2&ic=1[NC]

Now the images are messed up.

 

Let's say I have

 

www.mywebsite.com/quests

www.mywebsite.com/index

 

The Rewrite rule:

Options +FollowSymLinks

RewriteEngine on

RewriteRule (.*)/ index.php?page=$1

 

The pages would work, however, it also rewrites the images and CSS, etc.

 

How can I create a rewrite rule to stop this?

 

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.