seomike
06-03-2004, 04:31 PM
Ok if you haven't read the beginner thread you might want to give it a shot if you aren't understanding things in here.
What I'm going to go over is how to make a dynamic string with multiple variables looks static. There are many ways to do this. A good reference to this would be to take a look at www.nextag.com and see how they've seperated their variable using -s and ~s :).
Anyways let's assume we're wanting to turn our forum url into something static. So like before we're going to have to dive into the file and change the coding. Please note that some forums are way more dynamic then others. Invision Power Boards would be one of those that I'm talking about. Don't go rootin' around and changing the code or you may be screwing up something pretty bad. Best bet would be this, "If you understand how it works then you can tweek it".
Here what the link might look like:
www.somedomain.com/forum/thread.php?id=5555&f=45&do=view
Let's say our on page coding is this:
echo '<a href="forum/thread.php?id='.$db_var["id"].'&f='.$var1.'&do='.$var2.'">link text</a>';
We want to change it so it looks like this:
www.somedomain.com/forum45/thread5555.html
notice we took out the do=view. I'll explain that in a bit.
Here is what we'd do to the on page code:
echo '<a href="forum'.$var1.'/thread'.$db_var["id"].'\.html">link text</a>';
Now that we've rearranged things a bit I'll explain why I took out a variable. Sometimes a forum allow the admin to turn things on and off. For instance emoticon or avatars. Some forums may pass something similar like that through the url. If we know that do=view and it's controled by an on off switch by the admin we really don't need to pass it. We can just assume it's always on :D . We will how ever need to add it into our mod rewrite.
So let's mod rewrite away.
#Start mod
RewriteEngine On
Options +followsymlinks
RewriteBase /
RewriteRule ^forum([0-9]+)/thread([0-9]+)\.html$ /forum/thread.php?id=$2&f=$1&do=view
# end mod
So let's put this into english. We're going to look for a number that is 1 or more in lenght that is inbetween forum and /thread, and for a number that is 1 or more in length between /thread and .html. If we find a match save the numbers a variable and plug them into the query.
Notice that I've switched up how the $1 and $2 show up. in the query string. I did that because I swapped them in the url.
What I'm going to go over is how to make a dynamic string with multiple variables looks static. There are many ways to do this. A good reference to this would be to take a look at www.nextag.com and see how they've seperated their variable using -s and ~s :).
Anyways let's assume we're wanting to turn our forum url into something static. So like before we're going to have to dive into the file and change the coding. Please note that some forums are way more dynamic then others. Invision Power Boards would be one of those that I'm talking about. Don't go rootin' around and changing the code or you may be screwing up something pretty bad. Best bet would be this, "If you understand how it works then you can tweek it".
Here what the link might look like:
www.somedomain.com/forum/thread.php?id=5555&f=45&do=view
Let's say our on page coding is this:
echo '<a href="forum/thread.php?id='.$db_var["id"].'&f='.$var1.'&do='.$var2.'">link text</a>';
We want to change it so it looks like this:
www.somedomain.com/forum45/thread5555.html
notice we took out the do=view. I'll explain that in a bit.
Here is what we'd do to the on page code:
echo '<a href="forum'.$var1.'/thread'.$db_var["id"].'\.html">link text</a>';
Now that we've rearranged things a bit I'll explain why I took out a variable. Sometimes a forum allow the admin to turn things on and off. For instance emoticon or avatars. Some forums may pass something similar like that through the url. If we know that do=view and it's controled by an on off switch by the admin we really don't need to pass it. We can just assume it's always on :D . We will how ever need to add it into our mod rewrite.
So let's mod rewrite away.
#Start mod
RewriteEngine On
Options +followsymlinks
RewriteBase /
RewriteRule ^forum([0-9]+)/thread([0-9]+)\.html$ /forum/thread.php?id=$2&f=$1&do=view
# end mod
So let's put this into english. We're going to look for a number that is 1 or more in lenght that is inbetween forum and /thread, and for a number that is 1 or more in length between /thread and .html. If we find a match save the numbers a variable and plug them into the query.
Notice that I've switched up how the $1 and $2 show up. in the query string. I did that because I swapped them in the url.