954,116 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pff how quick u are ! Perfect for announcement.php ! Thanks dani!

yakusasci
Newbie Poster
16 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

A quick idea : the top of the top of the top - because now it's the top of the top ;) - would be for old indexed pages like showthread.php?t=23 ... to redirect to new urls with a 301 (moved permanently) header; is it possible ?

yakusasci
Newbie Poster
16 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

This is unfortunately not possible. Remember, behind the scenes, the .html pages are really just aliases for their php counterparts. If we do a 301 redirect on the php pages to redirect to the html pages, and then tell Apache that the html pages are aliases for the php pages, we're going to end up in an infinite loop, and no real page will ever be loaded.

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

Hi Dani. This is a very wicked tutorial, it looks like it took a lot of time and energy to create so thank you for sharing it with the rest of us lowely peons. :)

I have a question for you though... I noticed that the archive already makes use of more search engine friendly urls and I currently have the spiders redirected there with the spiders file. I was wondering what your thoughts were about keeping the spiders to the archive versus letting them crawl a mod_rewritten friendly url? Thanks!

PS: I had a bonus question since your the guru! I was thinking of useing mod_rewrite or something similar to include the thread names in the archive's url. I understand there is a performance hit but I'm trying to gauge what the trade off might be. Thanks again.

PhoenixDown
Newbie Poster
4 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

I think a good way to work the archive is the way that I did at http://www.daniweb.com/techtalkforums/post117122-12.html

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
This is unfortunately not possible. Remember, behind the scenes, the .html pages are really just aliases for their php counterparts. If we do a 301 redirect on the php pages to redirect to the html pages, and then tell Apache that the html pages are aliases for the php pages, we're going to end up in an infinite loop, and no real page will ever be loaded.

ok tks dani; that's what I thought. I've got a problem with showpost : dynamic link : showpost.php?p=262630&postcount=11 something I forgot ? tks !

yakusasci
Newbie Poster
16 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

This link would be in the postbit template - ensure it looks like the one posted in this tutorial.

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
Answers to your questions: (2) To make your archive work like a sitemap, where the links to the threads redirect to your *real* forum threads (mod_rewritten versions, of course!) then make the following two changes to your archive/index.php file. (Just as in the above tutorial, replace the first line with the second line) [html] echo "

$vbphrase[view_full_version] : $foruminfo[title]

\n\n"; echo "

$vbphrase[view_full_version] : $foruminfo[title]

\n\n"; echo "\t$thread[title]" . iif($pda, " (" . construct_phrase($vbphrase['x_replies'], $thread['replycount']) . ")") . "\n"; echo "\t$thread[title]" . iif($pda, " (" . construct_phrase($vbphrase['x_replies'], $thread['replycount']) . ")") . "\n"; [/html]


I tried these 2 line modification to my archive file. The index page would not even load. Is there anything need to be added in the .htaccess file also?

projectpilot
Newbie Poster
3 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 
This link would be in the postbit template - ensure it looks like the one posted in this tutorial.


ok it's perfect now. tks :) !

sorry but another problem : on online.php I get some

unknown place
/forum84-2-lastpost--25--1.html
unknown place
/post163310-3.html
unknown place
/thread13032-painter.html

for many lines it's ok.

yakusasci
Newbie Poster
16 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

By default, the hack only fixes the generic forum and thread URLs in Who's Online. It doesn't handle multiple pages or when search queries are used, etc. For a completely mod_rewritten Who's Online, make the following changes to the includes/functions_online.php file. In each instance, replace the commented out line (the line with the //) with the non-commented line that appears below it. The lines will appear in the same order within the file as noted below.

[php]
// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$forumtitle";
$userinfo['where'] = "$forumtitle";

// $userinfo['where'] = "$forumtitle";
$userinfo['where'] = "$forumtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$vboptions[bbtitle]";
$userinfo['where'] = "$vboptions[bbtitle]";

// $userinfo['where'] = "$forumtitle";
$userinfo['where'] = "$forumtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// edited by dani
/* $userinfo['where'] = "$threadtitle
" .
"$forumtitle"; */
$userinfo['where'] = "$threadtitle
" .
"$forumtitle";

// $userinfo['where'] = "$forumtitle";
$userinfo['where'] = "$forumtitle";

// $userinfo['where'] = "$forumtitle";
$userinfo['where'] = "$forumtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle"; }

// $userinfo['where'] = "$threadtitle";
$userinfo['where'] = "$threadtitle";

// $userinfo['where'] = "$vboptions[bbtitle]";
$userinfo['where'] = "$vboptions[bbtitle]";

// $userinfo['where'] = "$vboptions[bbtitle]";
$userinfo['where'] = "$vboptions[bbtitle]";

// $userinfo['where'] = "$vboptions[bbtitle]";
$userinfo['where'] = "$vboptions[bbtitle]";

[/php]

And then, below[php] convert_short_varnames($values);
$userinfo['values'] = $values;[/php]add[php]
// added by dani for seo hack
if (eregi("forum([0-9]+)", $filename, $fmatch))
{
$filename = 'forumdisplay.php';
$values['forumid'] = $fmatch[1];
}
if (eregi("thread([0-9]+)", $filename, $tmatch))
{
$filename = 'showthread.php';
$values['threadid'] = $tmatch[1];
}
if (eregi("threadnav([0-9]+)-([0-9]+)", $filename, $tmatch))
{
$filename = 'showthread.php';
$values['threadid'] = $tmatch[1];
}
if (eregi("threadmode([0-9]+)-(.*).html$", $filename, $tmatch))
{
$filename = 'showthread.php';
$values['threadid'] = $tmatch[1];
}
if (eregi("post([0-9]+)", $filename, $pmatch))
{
$filename = 'showthread.php';
$values['postid'] = $pmatch[1];
}
if (eregi("posted([0-9]+).html$", $filename, $pmatch))
{
$filename = 'showthread.php';
$values['postid'] = $pmatch[1];
}
if (eregi("postmode([0-9]+)-(.*).html$", $filename, $pmatch))
{
$filename = 'showthread.php';
$values['postid'] = $pmatch[1];
}
// added by dani for seo hack
[/php]

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

Excellent! Thank you Dani :) Great Tutorial

Polo
Newbie Poster
6 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 
I tried these 2 line modification to my archive file. The index page would not even load. Is there anything need to be added in the .htaccess file also?

I finally got that to work. The code for archive works fine. I just had to upload the "global.php" file again. I dont know what happened -- must have been an older version or something.

One more question Dani:

You said to use or tag for the titles. Can you elaborate a little. Do I just do the title of the page with h1 or h2? What did you mean by placing this code in the navbar:

$foruminfo[title]


Thanks for the answers to my earlier posts. Waiting for your answer before I make any changes.

projectpilot
Newbie Poster
3 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

It's an SEO technique to wrap important text or keywords that you wish to emphasize in H1 and H2 header tags. Therefore, in the SHOWTHREAD template, it's a good idea to put $foruminfo[title] and then use CSS to customize the look of the H1 tag. For more information, check out our Web Design forum :)

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 
By default, the hack only fixes the generic forum and thread URLs in Who's Online. It doesn't handle multiple pages or when search queries are used, etc. For a completely mod_rewritten Who's Online, make the following changes to the includes/functions_online.php file. In each instance, replace the commented out line (the line with the //) with the non-commented line that appears below it. The lines will appear in the same order within the file as noted below.

Tks for your help. It's better but I still get this just for this kind of pages :

/threadnav32724-2-18.html
/threadnav33609-3-18.html

Another question : do you know where I can change properties of the navbar for this :

DaniWeb IT Community > Site Management and Internet Marketing > Web Hosting > Web Hosting Tutorials > vBulletin mod_rewrite for vB 3.0.7

I'd like to add a title attribute for forums links.

Tks.

yakusasci
Newbie Poster
16 posts since Apr 2005
Reputation Points: 10
Solved Threads: 0
 

Sorry for postining in the wrong place. I'll try here.

Hullo I'm new here and must say that I'm very impressed with this mod_rewwrite.

However, I have been looking at the most updated version and am a trying to incorporate this but am confussed by the following.

I have noted this:- Below are the PHP files that need to be edited. You will notice two lines at a time. The first line represents what to search for, and the second line represents what to replace it with.

So without further ado ...

$highlightwords = '&highlight=' . urlencode(implode(' ', $display['highlight']));
$highlightwords = '-' . urlencode(implode(' ', $display['highlight']));

$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';
$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';
[/html]

showthread.php

[html]$highlightwords = iif($goto, '&', '&') . 'highlight=' . urlencode($_GET['highlight']);
$highlightwords = '-' . urlencode($_GET['highlight']);

exec_header_redirect("showthread.php?$session[sessionurl_js]p=$getlastpost[postid]$highlightwords#post$getlastpost[postid]");
exec_header_redirect("threadedpost$getlastpost[postid]$highlightwords.html#post$getlastpost[postid]");

exec_header_redirect("showthread.php?$session[sessionurl_js]p=$posts[postid]$highlightwords#post$posts[postid]");
exec_header_redirect("threadedpost$posts[postid]$highlightwords.html#post$posts[postid]");

exec_header_redirect("showthread.php?$session[sessionurl_js]t=$threadinfo[threadid]&goto=lastpost$highlightwords");
exec_header_redirect("lastpostinthread$threadinfo[threadid]$highlightwords.html");

exec_header_redirect("showthread.php?$session[sessionurl_js]t=$thread[pollid]");
exec_header_redirect("thread$thread[pollid].html");

$pagenav = construct_page_nav($totalposts, "showthread.php?$session[sessionurl]t=$threadid", "&pp=$perpage$highlightwords");
$pagenav = construct_page_nav($totalposts, "threadnav$threadid", "-$perpage$highlightwords.html");

$firstunread = 'showthread.php?' . $session['sessionurl'] . 't=' . $threadid . '&goto=newpost';
$firstunread = 'newpostinthread' . $threadid . '.html';

$pagenav = construct_page_nav($numhybrids, "showthread.php?$session[sessionurl]p=$_REQUEST[postid]", "&pp=$perpage$highlightwords");
$pagenav = construct_page_nav($numhybrids, "post$_REQUEST[postid]", "-$perpage$highlightwords.html");

$navbits["forumdisplay.php?$session[sessionurl]f=$forumID"] = $forumTitle;
$navbits["forum$forumID.html"] = $forumTitle;


I can see that I remove line 4. But from the layout of the code it seems that the replacement code exceeds more than 1 line. To me I think that I should replace with lines 5, 6, 7, 8, 10 and 11.

Sorry for not understanding fully.

Jezella

Jezella
Newbie Poster
9 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

Take showthread.php for example:

Replace

[php]$highlightwords = iif($goto, '&', '&') . 'highlight=' . urlencode($_GET['highlight']);[/php]

with

[php]$highlightwords = '-' . urlencode($_GET['highlight']);[/php]

Then replace

[php]exec_header_redirect("showthread.php?$session[sessionurl_js]p=$getlastpost[postid]$highlightwords#post$getlastpost[postid]");[/php]

with

[php]exec_header_redirect("threadedpost$getlastpost[postid]$highlightwords.html#post$getlastpost[postid]");[/php]


etc.

cscgal
The Queen of DaniWeb
Administrator
19,421 posts since Feb 2002
Reputation Points: 1,474
Solved Threads: 229
 

Got it real fab is this and seems to work a treat. Now I just have to set it up on the main forum and not the testing one.

I did misunderstand the following bits in your code and hope that what I have now done is correct.

$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';
$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';
[/html]

showthread.php

[html]$highlightwords = iif($goto, '&', '&') . 'highlight=' . urlencode($_GET['highlight']);
$highlightwords = '-' . urlencode($_GET['highlight']);


$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';
$display['forums']["$key"] = "" . $forumcache["$forumid"]['title'] . '';


//[/html] deleted this

Next file to change

showthread.php

//[html] deleted this

$highlightwords = iif($goto, '&', '&') . 'highlight=' . urlencode($_GET['highlight']);
$highlightwords = '-' . urlencode($_GET['highlight']);

Many thanks

Jezella

Jezella
Newbie Poster
9 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

I know that another hack added to this most wonderful one posted here may not be right but I have found the following white space remover that helps pages load faster.

Here the link http://www.vbulletin.org/forum/showthread.php?t=69787

I have incorporated this also and set store CSS Styles Sheets as files to yes. With these 2 additional changes to my forum, page display is really fast.

The question is that as re_write is being used in this hack, could this additional white space remove cause a problem which I have not noticed. I have done a bit of testing and it appears not. However, I am far from an expert.

Comments would be appreciated.

I'm feeling good, I'm learning something.

Jezella

Jezella
Newbie Poster
9 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

Great hack cscgal.
When you say "not for the faint hearted", you aren't kidding.
I recommend to anyone to edit a test board first if you can (I did mine on a exact copy child forum of my default forum first), and BACKUP!

Anyway, I did have a problem with the 'RewriteRule ^threadmode' section in the htaccess file I uploaded. It crashed the site. Don't know why. But I removed those sections for the 'threadmode' RewriteRule and it when back to normal. Also removed the template edits related to same. I don't mind, as I don't let visitors see the mode options anyway, and I removed the Hybrid option a while ago. I don't like the hybrid mode and 90% of my members said they never use it. Also didn't include the online part. I only allow it for members only.

Didn't do the archive in full either. I think part of showing the archives to bots is that they see the unformatted text of the posts (no graphics, etc). They seem to like that. But I did put in the 'View Full Version' links to point to the rewrite htmls'.

But for that, it works like a charm!
If you care to - << url snipped to comply with forum policy >>

I also have a hack named, 'Most Recent Posts', and I replaced the urls in there also. Works fine.

And, I also edited my vBAdvanced CMPS portal for the rewrite. cscgal, if you don't mind, I'll PM you the edits for you to check out. It works fine on my Forum, but you may want to look at my code edits first. << url snipped >>

John

wirewolf
Newbie Poster
3 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

Well here are my suggestions...

I would recommend making the instruction more clear... as they are right now I think people will find them confusing...

and fix them alittle bit, because right now there is some html tags that are appearing that shouldnt be there...

$forumcache["$forumid"]['title'] . ''; [/html]

showthread.php

[html]$highlightwords = iif($goto, '&', '&') . 'highlight=' .

and also, it would be great if you could post the template modifications as many (like me) have modified their forums templates alot, and just replacing the new templates will revert all of their custom templates...

just my suggestions :) thank you for evertyig dani, this hack is really good :)

Polo
Newbie Poster
6 posts since Sep 2004
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
 
View similar articles that have also been tagged: