Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

301 Redirect Or Rewrite Rule?


  • Please log in to reply
5 replies to this topic

#1 ColinB

ColinB

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 15 January 2010 - 07:42 AM

Hi - first post here so please be gentle!

For a few years now I've been running a phpBB forum - up to phpBB3 - which has been well indexed and has received a decent amount of traffic. However, I recently decided to close it (for all sorts of reasons that aren't relevant here) but of course I have the problem that I don't want loads of 404 errors turning up in my logs. Obviously, I'm just throwing opportunity to the wind.

What's the best way to re-direct all requests to a specified landing page (within a recent new Wordpress install, as it happens)?

I'm using a WP plug-in that enables me to manage requests without having to edit the htaccess file and I'm currently doing this fine for static pages, but I just don't know to redirect everything below the "forums" directory.

Should this be done using 301 handlers or does it require a rewrite condition rule within htaccess itself? (And, if the latter, what should this be?).

Good advice gratefully received!

Colin

#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 15 January 2010 - 11:09 AM

So everything in the forum was in a /forums/ subdirectory then? This should make it pretty easy if this structure is no longer being used.

Hard to say if it's something you can do via the WP Plugin or will need to edit the .htaccess file. The latter will work for sure. The Plugin could be writing stuff to the .htaccess file, or may be using a script that only controls WP addresses.

The .htaccess way of doing it would look like

CODE
RewriteCond %{REQUEST_URI} ^/forums(/)?
RewriteRule ^(.*)$ http://www.domain.com/somepage.html? [R=301,L]


The above would 301 redirect all "forums" traffic to /sompage.html, stripping off any query strings that might be present. From a usability perspective you might also want to consider delivering those folks to some interim page for at least a time to let them know the forum is now gone. As opposed to going to a page that doesn't talk about the forum at all.

#3 ColinB

ColinB

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 15 January 2010 - 01:30 PM

Hi Randy

Thanks hugely for the quick response. I've given your suggestion a go and here's what happens:

Let's use this original phpBB page as an example (having now been removed and therefore returning a 404):

Request forum page

CODE
http://www.simplydv.co.uk/simplyBB/viewtopic.php?f=27&t=10490&start=0


where the forums installation directory is /simplyBB/ (case-sensitive).

I've created a new content-related landing page as per your suggestion and saved the .htaccess file back to the domain root as follows:

CODE
RewriteCond %{REQUEST_URI} ^/simplyBB(/)?
RewriteRule ^(.*)$  http://www.simplydv.co.uk/old-simplydv-forums-closed/? [R=301,L]

but it still returns a 404 in the new Wordpress install. Does this have something to do with the WP page-naming convention (eg: forward-slash on the end but no "pagename+ext"? I realise that the latter isn't necessary but I'm wondering if the last forward-slash is doing something it shouldn't.

One thing to consider. The domain is running within my webspace that contains other domains. This one uses Hostgator's CPanel redirects to point simplydv.co.uk into a folder within the root of simplydv.tv/uk/. This is what's in the same file:

CODE
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /uk/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


This won't interfere will it?

The htaccess file I'm using here is the one that's within the root of the /uk/ "home directory" as created by the Wordpress install. It may be superfluous but I thought I'd mention it.

Thanks again for any help you can offer.

Colin

#4 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 15 January 2010 - 03:58 PM

It may be a conflict Colin.

An important thing to remember is read and processed from the top down. So what you may want to try is inserting your new 301 in there directly after the RewriteEngine on line to see what happens.

Is it safe to assume the "simplyBB" text string is totally unique to only the forum pages? Meaning it's not being used anywhere else as part of a file name?

If so, I'd do it like:

CODE
RewriteCond %{REQUEST_URI} ^/simplyBB(.*)
RewriteRule ^(.*)$  http://www.simplydv.co.uk/old-simplydv-forums-closed/? [R=301,L]


The new wildcard at the end of the RewriteCond opens things up a good bit more, but as long as it's unique it'll be more apt to catch all requests and redirect them.

#5 ColinB

ColinB

    HR 1

  • Members
  • Pip
  • 3 posts

Posted 15 January 2010 - 06:24 PM

Hi Randy

Been out for the evening (I'm in the UK) and have been desperate to get back to test things..... (OK, that's sad!)...

QUOTE(Randy @ Jan 15 2010, 08:58 PM) View Post
Is it safe to assume the "simplyBB" text string is totally unique to only the forum pages? Meaning it's not being used anywhere else as part of a file name?


Yes, definitely.

QUOTE(Randy @ Jan 15 2010, 08:58 PM) View Post
If so, I'd do it like:

CODE
RewriteCond %{REQUEST_URI} ^/simplyBB(.*)
RewriteRule ^(.*)$  http://www.simplydv.co.uk/old-simplydv-forums-closed/? [R=301,L]


The new wildcard at the end of the RewriteCond opens things up a good bit more, but as long as it's unique it'll be more apt to catch all requests and redirect them.


Hmmm. I can see the logic of that. However, I tried it and it still doesn't work, so it should be safe to assume a conflict somewhere. Trouble is that I can't remove the existing rewrite rule that's in .htaccess (the only one) because that's what governs the domain location so am I stumped?

It's late night here as I type but I'll have another fiddle in the morning.

Once again, your help is appreciated.

Cheers - Colin

PS: Sorry about my omission of "code" tags, above. You'd think that after running phpBB forums for 8 years I'd think of such things! It's weird being on the "user" side of the fence! :-)


#6 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 16 January 2010 - 11:27 AM

If it's a conflict simply test different things in the order.

Inserting the redirect before the WP instructions should have no detrimental effect. The redirect will only fire if/when its conditions are met, and its conditions should not be met when someone is accessing one of your blog pages.

Another way to do this and save a tiny bit of processing would be to keep the simplyBB folder live on your server and place the redirect in an .htaccess there. Shouldn't be necessary in this case, but it an alternate approach. It would then only fire if/when someone tried to access a page that used to live in this simplyBB subdirectory.

<Edit to add>
Oh, and just to mention it...

Make sure your browser isn't pulling stuff from it's Cache. This could give you a false impression of what's really happening on the server level too. That's why I prefer to use a tool like WebBug when working with/on redirects. It doesn't cache stuff. wink1.gif Just make sure you always check off HTTP Ver 1.1 if you use WebBug. It defaults to 1.0, which was incredibly buggy where status codes are concerned.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
 
No new posts or registrations allowed.