Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rewrite for new forum software to redirect links from Google

.htaccess smf phpbb rewrite url

         

HappyMonkey

3:28 am on Oct 6, 2009 (gmt 0)

10+ Year Member



We recently moved our site over from a SMF forum to PHPBB (both via Joomla). Topic numbers stayed the same going across to the new forum so a rewrite should be ideal. However after looking at MANY sites I'm totally confused as to how to do the rewrite. I'm sure I've even looked at exact examples, but they aren't making sense!

We need to take the URL's like this one:
[mydomain.com...]

and change them to:

[mydomain.com...]

The only part that needs to be carried from the old to the new is the #*$!x, everything else is static. So I just need to figure out how to grab the #*$!x from the first url, and rewrite is as the second url.

We're on a Linux / Apache II server with Mod_rewrite. We have some other rewrites working fine (which don't affect any of the forum URL's).

Any ideas, suggestions or links to easily understood and relevant tutorials gratefully appreciated. I've been trying to figure this out for hours! And it's been months since we shifted.. we're worried Google will drop the links any day!

jdMorgan

3:54 am on Oct 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_rewrite uses pattern-matching -- both to detect when a requested URL-path matches and the rule should be invoked, and to 'capture' all or part of the requested URL, so that it can be back-referenced in the rule's substitution URL (or filepath).

Take a look at the resources cited in our Apache Forum Charter, and the example threads in our Apache Forum Library. Links to both are at the top of this page. The terms in italics above are important to your research.

I do note that the itemid appears to have changed, so you might want to mention the scope and/or variability of that parameter as well; If there are multiple itemids and they really do differ as shown above (12->18), then you'll either need one rule for each, you'll need to use a RewriteMap to translate them (requires server config access), or you'll need to call a script to translate them. The good news is that other than that issue (which may be a non-issue), this is a fairly trivial application of mod_rewrite.

Jim

HappyMonkey

4:01 am on Oct 6, 2009 (gmt 0)

10+ Year Member



Thanks... the item id is always going to be the same, so there's no need to pattern match there. 12 was the old forum number assigned, and 18 is the new one. They are always the same... 12 in the old url's and 18 in the new.

Funny the forum changed my strong of 4 x's to '#*$!x', a rather strange string of characters!

I know this should be simple... but looking at all the examples just somehow doesn't make sense to me. I think when you don't get the basic syntax, even a clear example is sometimes hard to read. I will look again.

HappyMonkey

4:11 am on Oct 6, 2009 (gmt 0)

10+ Year Member



The Apache rewrite guide in the charter seems to have an invalid url.... it just attempts to load forever.

jdMorgan

4:13 am on Oct 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteRule ^pattern-to-match-the-old-URL-path$ http://www.example.com/new-URL-path [R=301,L]

Everything else is regular-expressions patterns and back-references. See the resources in our Charter.

x-x-x is in our 'bad word filter' to deter/defeat drive-by link spammers. Try 'xyz' instead.

Jim

HappyMonkey

4:16 am on Oct 6, 2009 (gmt 0)

10+ Year Member



Maybe this is the same one?
[fas.org...]

g1smd

10:47 pm on Oct 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One question...

Do you really want Google to see all new URLs for the content, as seen in the links on your pages, and a 301 redirect if the old version of a URL is requested?

OR

Do you want to carry on using the same URLs for all of your content, and employ a rewrite to silently connect the requested URL with the new internal filepath inside the server?

HappyMonkey

11:12 pm on Oct 6, 2009 (gmt 0)

10+ Year Member



Our intension was to actually show the new URL's, but to direct all the traffic from Google coming to the old ones to the new pages with the content on them. It's a few thousand a month so well worth capturing.

How does this look:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^component/option,com_smf/Itemid,71/topic,(.+).msg(.+)$ [oursite.com...] [R=301,L]

g1smd

11:15 pm on Oct 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well, you're asking Google to look at a more complex URL, going from one with folder-like properties, to one with parameters.

The URLs with parameters will work whatever the parameter order - and that's a Duplicate Content issue.

What you want to do is the exact opposite of what I would want to do in this situation.

jdMorgan

2:13 am on Oct 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, if you care about search engine ranking, it might be good to stop coding right now and go spend a week or two researching number-of-parameters and length-of-URL effects on rankings.

Now is the time to design and implement an organized, flexible, maintainable, and expandable SEO-friendly architecture for your new URLs. As it is, it appears that you intend to go from fairly-ugly, fairly-bad URLs to really-ugly, really-bad URLs. This is meant only as friendly advice...

Jim