Reply
Tue 25 May, 2004 09:27 pm
I would like to adjust your mod to contain keywords in the URL string for guests. For example, instead of:
website.org/forum-1.html
I would like to have:
website.org/forum-1-keyword1-keyword2-keyword3.html
Google loves keywords in the URL string, so this could be dynamite. I already tested this with static keywords, and it works. However, I need help with implementing dynamic keywords.
Somehow I need to adjust the replace_for_mod_rewrite function in the page_header.php file to include {PAGE_TITLE}. If {PAGE_TITLE} was passed to this function, I could manipulate it like this:
*** Code assumes {PAGE_TITLE} is passed to replace_for_mod_rewrite function as $page_title ***
//separates $page_title into separate keywords
$keyword_array = explode(" ", $page_title);
//takes URL unfriendly characters out of keywords
for ($j=0; $j<count($keyword_array); $j++)
{
$patterns = array(";", "@", "?", ":", "=", "&",
"<", ">", '"', "#", "[", "]",
"%", "{", "}", "|", "^", "~",
"/", "\\", "`", "$");
$replacements = "";
$keyword_array[$j] = str_replace($patterns, $replacements, $keyword_array[$j]);
}
//Glues the keywords back together, separated by dashes
$keyword_string = implode("-", $keyword_array);
Then within the $urlout array, the keyword string would be part of the replacement like this:
$urlout = array(
forum-\\1-$keyword_string.html
);
I was hoping someone could help me who knows much more than me about the framework of PHPBB and the SEO mod. Thanks a lot!!!
I might be able to work on keyword URLs in the future but right now I'm too busy.
I might have more time in about 2-4 weeks.
From a quick glance at your code, what I'd change is to not make the title an array of words and just str_replace the spaces with dashes.
But then again maybe I'd use the array to create dynamic keyword meta tags...
Lots of possibilities, I'll definitely tackle this sometime, but hopefully someone else will get to it before then. Google really does like URL words and it's a good idea.
Thanks
Thanks for the response and suggestions. I think I'm close to figuring this out, so I will let you know how it goes in case you would like to include it in your next version.
Keywords in URL's
I don't know what I was talking about with wanting the Page Title in the link. I completed this, and I realized this is not what I was looking for at all.
However, I started to change my index page, and now my forum links from the index page have keywords in the URL. If you would like to see this in action, go to extremeblitz.com/forum/. Here is my code so far, I was wondering if you could glance at it and pick out anything that's inefficient:
OPEN index.php
FIND
$template->assign_block_vars('catrow.forumrow', array(
Before, ADD
if ( !$userdata['session_logged_in'] )
{
$forum_name = $forum_data[$j]['forum_name'];
$forum_url_keywords = strtolower($forum_name);
$forum_url_keywords = preg_replace("/[^A-Za-z0-9 -]/", "", $forum_url_keywords);
$forum_url_keywords = str_replace(" ", "-", $forum_url_keywords);
$forum_url_keywords = "-$forum_url_keywords.html";
}
FIND
'FORUM_NAME' => $forum_data[$j]['forum_name'],
After, ADD
'FORUM_URL_KEYWORDS' => $forum_url_keywords,
FIND
'FORUM_NAME' => $forum_data[$j]['forum_name'],
REPLACE WITH
'FORUM_NAME' => $forum_name,
OPEN index_body.tpl
FIND
<a href="{catrow.forumrow.U_VIEWFORUM}
After, ADD
{catrow.forumrow.FORUM_URL_KEYWORDS}
OPEN page_header.php
FIND
"forum-\\1.html",
REPLACE WITH
"forum-\\1",
It's looking good. What code are you using for the viewforum files?
I might get a chance to tidy it up shortly seeing as you have some code to work off of.
What I need to do is research any other charachters that might be URL unfriendly and/or redo the .htaccess rewrite rules.
View Forum
Here are my changes for the viewforum page. By the way, I changed the code so that only alphanumeric characters are allowed in the URL string.
OPEN viewforum.php
FIND
$topic_title = ( count($orig_word) ) ? preg_replace......
After, ADD
if ( !$userdata['session_logged_in'] )
{
$topic_url_keywords = strtolower($topic_title);
$topic_url_keywords = preg_replace("/[^A-Za-z0-9 -]/", "", $topic_url_keywords);
$topic_url_keywords = str_replace(" ", "-", $topic_url_keywords);
$topic_url_keywords = "-$topic_url_keywords.html";
}
FIND
'TOPIC_TITLE' => $topic_title,
After, ADD
'TOPIC_URL_KEYWORDS' => $topic_url_keywords,
OPEN viewforum_body.tpl
FIND
<a href="{topicrow.U_VIEW_TOPIC}
After, ADD
{topicrow.TOPIC_URL_KEYWORDS}
OPEN page_header.php
FIND
"about\\1.html",
REPLACE WITH
"topic-\\1",
OPEN .htaccess
FIND
RewriteRule ^about([0-9]*).* viewtopic.php?t=$1 [L,NC]
REPLACE WITH
RewriteRule ^topic-([0-9]*).* viewtopic.php?t=$1 [L,NC]
Looks good, you inadvertently took care of one of the problems I'd planned to address.
Test topics with "topic" and "topic-" in the title and see if they are rewritten correctly on your test board.
Strum4life
Is this mod 100% ready to go?
As it would be surely be a great addition
One other quick question!
Regarding pictures on a forum! will search engines bots pick them up and go to the site of origin just like a normal link?
Locan,
No, it's not ready.
strum4life,
BTW, you are getting errors on forums with multiple pages.
Any status on this feature request?
Or is it worked into another thread already.
I know that Google give large weight to keywords in urls, especially file names rather than directories.
I really like this mod, thanks for bringing it out
it seems v close to being a perfect solution
i get these urls
forum/about1.html for forum
and
forum/about1.html%20-this%20is%20my%20post.html for posts
am i doing something wrong or is it supposed to work like this?
It seems like this mod is trying to do something like this
forum/about1/ for forum
and this
forum/about1/this-is-my-post.html for post
not sure what I am doing wrong but any guidance would be much appreciated
qwerky wrote:I really like this mod, thanks for bringing it out
it seems v close to being a perfect solution
i get these urls
forum/about1.html for forum
and
forum/about1.html%20-this%20is%20my%20post.html for posts
am i doing something wrong or is it supposed to work like this?
It seems like this mod is trying to do something like this
forum/about1/ for forum
and this
forum/about1/this-is-my-post.html for post
not sure what I am doing wrong but any guidance would be much appreciated
I don't know if it's your mod or not but a new rewrite mod using keywords is ready to use:
http://www.phpbbhacks.com/download/4702
But the problem is, I already use able2know mod_.rewrite. If I'll use this new mod, all my URL's will be replaced with these new keyword rich URL's. The pages, which are indexed by google, will be not accessable anymore. How can we prevent this?
Using this on my site now and it works great, thx! :wink:
I would very much like to know how to make the keyword mod_rewrite work while still keeping the old urls in search engine's alive.
jseamless wrote:I would very much like to know how to make the keyword mod_rewrite work while still keeping the old urls in search engine's alive.
This was exactly what I ment.
Links from results are still working for me :wink:
993ti wrote:Links from results are still working for me :wink:
Are you still using both of the mods together?
Can you post the code changes that you've made? I've applied the new keyword mod without removing able2know's mod, but the new one did not work.
I'm using Craven's rewrite with the mod posted in this topic.
If you're using Webmedics rewrite, uninstall Cravens but leave the code in htaccess.
I did exactly what you wrote, but it didn't work
looks like an interesting topic.. hopefully we can get some input on this