Forum Moderators: phranque

Message Too Old, No Replies

Rewrites

htaccess rewrites

         

Bridge

10:49 am on Nov 25, 2004 (gmt 0)

10+ Year Member



Need solid help here.

I have updated my site to a newer version of google friendly urls, using .htaccess rewrites and header url in and out arrays, (I use a CMS with long php urls) which has resulted in many entries in google which now lead to dead links such as these:

/postx395-0-0.html
/forums-profile-viewprofile-u-1335.html
/postt498.html
/forumsgroupcp-g-11.html
/posts1114-highlight.html
/postp1878.html
/forums-posting-quote-p-1971.html
/forums-posting-reply-t-554.html

I am going with the new format of html rewrites as they do make more sense than the old ones, though I "desperately" need a way of keeping the old links working in google for the time being (there are thousands), until google re-indexes my site and updates with the new ones. Obviously I rely on the now dead ones for traffic and therefore income!

I was thinking some kind of redirect would work, but obviously I can't enter an individual link for each postID in the .htaccess, it would be far too long.

Anyone?

Bridge

1:33 pm on Nov 25, 2004 (gmt 0)

10+ Year Member



I figured you buys would probably need more information than I posted above. Here then are the htaccess rewrites, the old ones (non active) first:

#Forums
#RewriteRule ^forumx([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewforum&f=$1&topicdays=$2&start=$3 [L]
#RewriteRule ^forum([1-9][0-9]*)-(mark存tart)([a-zA-Z0-9_]*).html modules.php?name=Forums&file=viewforum&f=$1&$2=$3 [L]
#RewriteRule ^forum([1-9][0-9]*).* modules.php?name=Forums&file=viewforum&f=$1 [L]
#RewriteRule ^postx([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewtopic&t=$1&start=$2&postdays=$3&postorder=asc&highlight= [L]
#RewriteRule ^postxf([0-9]+)-([0-9]+)-([0-9]+).html modules.php?name=Forums&file=viewtopic&t=$1&postdays=$2&postorder=asc&start=$3 [L]
#RewriteRule ^posts([0-9]*)-(start宅iew多ighlight)([[:punct:]/:\-\'(){}.&=_a-zA-Z0-9\ ]*).html modules.php?name=Forums&file=viewtopic&t=$1&$2=$3 [L]
#RewriteRule ^topic([1-9][0-9]*)-([a-zA-Z0-9]*).html modules.php?name=Forums&file=viewtopic&t=$1&$2=topic&start=0 [L]
#RewriteRule ^post(p宇)([1-9][0-9]*).* modules.php?name=Forums&file=viewtopic&$1=$2 [L]
#RewriteRule ^register-coppa-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=profile&mode=register&agreed=true&coppa=$1 [L]
#RewriteRule ^register-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=profile&mode=register&agreed=$1 [L]
#RewriteRule ^poster([a-zA-Z0-9_]*)-([0-9_&]*)_([a-zA-Z0-9_&=[:punct:]\.\;]*).html modules.php?name=Forums&file=modcp&mode=$1&p=$2&t=$3 [L]
#RewriteRule ^modcp([0-9]*)-([a-zA-Z0-9]*).html modules.php?name=Forums&file=modcp&t=$1&mode=$2 [L]
#RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([0-9]*)-([1-9][0-9]*).html modules.php?name=Forums&file=$1&mode=$2&t=$3&popup=$4 [L]
#RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-(p宇圩守如opup)-([0-9]*).html modules.php?name=Forums&file=$1&mode=$2&$3=$4 [L]
#RewriteRule ^forums-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1&mode=$2 [L]
#RewriteRule ^forum([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=search&$1=$2&$3=$4 [L]
#RewriteRule ^forums([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*)-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1&$2=$3 [L]
#RewriteRule ^forums.html modules.php?name=Forums&file=index [L]
#RewriteRule ^forum-([a-zA-Z0-9_]*).html modules.php?name=Forums&file=$1 [L]
#RewriteRule ^forums.html modules.php?name=Forums [L]

RewriteRule ^ftopic-([0-9]*)-([0-9]*)-days([0-9]*)-order(desc地sc)-([A-Za-z0-9_-]*).html modules.php?name=Forums&file=viewtopic&t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L]
RewriteRule ^ftopic-([0-9]*)-days([0-9]*)-order(desc地sc)-([0-9]*).html modules.php?name=Forums&file=viewtopic&t=$1&postdays=$2&postorder=$3&start=$4 [L]
RewriteRule ^ftopic-([0-9]*)-([0-9]*).html modules.php?name=Forums&file=viewtopic&t=$1&start=$2 [L]
RewriteRule ^ftopic-([0-9]*)-(previous好ext).html modules.php?name=Forums&file=viewtopic&t=$1&view=$2 [L]
RewriteRule ^ftopic(t如)-([0-9]*)-([A-Za-z0-9_-]*).html modules.php?name=Forums&file=viewtopic&$1=$2&highlight=$3 [L]
RewriteRule ^ftopic-([0-9]*)-(watch守nwatch)-([0-9]*).html modules.php?name=Forums&file=viewtopic&t=$1&$2=topic&start=$3 [L]
RewriteRule ^ftopic(t如)-([0-9]*).html modules.php?name=Forums&file=viewtopic&$1=$2 [L]
RewriteRule ^ftopic(t如)-([0-9]*).html#([0-9]*) modules.php?name=Forums&file=viewtopic&$1=$2#$3 [L]
RewriteRule ^forum-editprofile.html modules.php?name=Forums&file=profile&mode=editprofile [L]
RewriteRule ^forum-userprofile-([0-9]*).html modules.php?name=Forums&file=profile&mode=viewprofile&u=$1 [L]
RewriteRule ^forum-register-new.html modules.php?name=Forums&file=profile&mode=register&agreed=true [L]
RewriteRule ^forum-register-coppa.html modules.php?name=Forums&file=profile&mode=register&agreed=true&coppa=true [L]
RewriteRule ^forum-register.html modules.php?name=Forums&file=profile&mode=register [L]
RewriteRule ^forums-posting.html modules.php?name=Forums&file=modules&name=Forums&file=posting [L]
RewriteRule ^forum-faq-bbcode.html modules.php?name=Forums&file=faq&mode=bbcode [L]
RewriteRule ^ftopic-post-([0-9]*).html modules.php?name=Forums&file=posting&t=$1 [L]
RewriteRule ^ftopic-vote-([0-9]*).html modules.php?name=Forums&file=posting&mode=vote&t=$1 [L]
RewriteRule ^ftopic-new-([0-9]*).html modules.php?name=Forums&file=posting&mode=newtopic&f=$1 [L]
RewriteRule ^ftopic-reply-([0-9]*).html modules.php?name=Forums&file=posting&mode=reply&t=$1 [L]
RewriteRule ^ftopic-edit-([0-9]*).html modules.php?name=Forums&file=posting&mode=editpost&p=$1 [L]
RewriteRule ^ftopic-smilies.html modules.php?name=Forums&file=posting&mode=smilies&popup=1 [L]
RewriteRule ^ftopic-quote-([0-9]*).html modules.php?name=Forums&file=posting&mode=quote&p=$1 [L]
RewriteRule ^forum-posting.html modules.php?name=Forums&file=posting [L]
RewriteRule ^forums-group([0-9]*).html modules.php?name=Forums&file=groupcp&g=$1 [L]
RewriteRule ^fsearch-author-([a-zA-Z0-9_-]*).html modules.php?name=Forums&file=search&search_author=$1 [L]
RewriteRule ^fsearch-([0-9]*)-([0-9]*).html modules.php?name=Forums&file=search&search_id=$1&start=$2 [L]
RewriteRule ^fsearch-(unanswered圯gosearch好ewposts).html modules.php?name=Forums&file=search&search_id=$1 [L]
RewriteRule ^fsearch-results.html modules.php?name=Forums&file=search&mode=results [L]
RewriteRule ^forums-([^index][a-zA-Z0-9_-]*).html modules.php?name=Forums&file=$1 [L]
RewriteRule ^forum-c([0-9]*).html modules.php?name=Forums&file=index&c=$1 [L]
RewriteRule ^forum-mark.html modules.php?name=Forums&file=index&mark=forums [L]
RewriteRule ^forums.html modules.php?name=Forums&file=index [L]
RewriteRule ^forum-viewonline.html modules.php?name=Forums&file=viewonline [L]
RewriteRule ^forum-([0-9]*)-days([0-9]*)-([0-9]*).html modules.php?name=Forums&file=viewforum&f=$1&topicdays=$2&start=$3 [L]
RewriteRule ^forum-([0-9]*)-([0-9]*).html modules.php?name=Forums&file=viewforum&f=$1&start=$2 [L]
RewriteRule ^forum-([0-9]*)-mark.html modules.php?name=Forums&file=viewforum&f=$1&mark=topics [L]
RewriteRule ^forum-([0-9]*).html modules.php?name=Forums&file=viewforum&f=$1 [L]
RewriteRule ^forums.html modules.php?name=Forums [L]

The question then is how do I make the old ones continue to work, leading to the newer ones?

Please excuse the newbie nature here guys!

dcrombie

3:55 pm on Nov 25, 2004 (gmt 0)



You need to redirect the old patterns to the new ones using [R=301]. That will redirect browsers to the new address and let the search spiders know that the old address is deprecated.

RewriteRule oldpattern newpattern [R=301]

;)

Bridge

10:37 pm on Nov 25, 2004 (gmt 0)

10+ Year Member



Thanks heaps.

Could you please include just a one line example to give me a start.

Thanks

Bridge

11:40 am on Nov 26, 2004 (gmt 0)

10+ Year Member



To give you an example I have tried this:

This is the dead link:

[widget.com...]

In the .htaccess I tried this:

RewriteRule ^forum([1-9][0-9]*).* [widget.com...] [R=301]

Which gives a dead url, which has changed but is of this form:
[widget.com...]

It should be [widget.com...]

Anyone?

dcrombie

11:50 am on Nov 26, 2004 (gmt 0)



This should work:

RewriteRule ^forum([1-9][0-9]*) /forum-$1.html [R=301]

Bridge

4:46 pm on Dec 17, 2004 (gmt 0)

10+ Year Member



Thanks.