Migrating from phpbb2 & old SEO - URL troubles

Discussions about the phpBB3 Forum. How to get the best from this powerful script.
Note that there is no official support for phpBB3 here, a place to share more than to ask for.

Moderator: Moderators

Migrating from phpbb2 & old SEO - URL troubles

Postby PCGUY112887 » Mon Oct 14, 2013 7:18 pm

Hello!

First of all, great worth with the SEO mod. I love this!

I decided to upgrade to phpBB3 and change my URL's all at the same time with the new SEO mod. I'm having a few troubles however...

I have these old links, posted on other websites/etc. They are in this format (you can see the old SEO)
I already have a script in place to drop the /forums/ part since my root phpBB install resides in the root of my server not /forums/ anymore.

I need to get them into my new format, which includes forum titles and all. I figure that's a bit hard to directly rewrite, so I'm trying to make this... (I'm chopping off http and www because I can't post more than 1 link as a new user)

spudfiles.com/viewtopic,p,310599.html#310599

Into This

spudfiles.com/viewtopic.php?p=310599

As you can see, the bottom link gets redirected beautifully to it's fully URL. I need to ensure I carry the variables over properly for the post ID, but I don't know how to do that.

Any help? Thank you!!!
PCGUY112887
 
Posts: 4
Joined: Mon Oct 14, 2013 6:58 pm

Advertisement

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby HB » Mon Oct 14, 2013 8:50 pm

I don't know what you mean by the "old SEO", but I'll guess that it's another URL format. If so, you can rewrite it to the "standard" phpBB format and let that redirect to the phpBB-SEO format.

Code: Select all
RewriteRule ^viewtopic\,p\,([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]


The # anchor isn't included in the rewrite, so you can't change it. The QSA flag will append any ? parameters that happen to be there (e.g., start=).

UPDATE: Corrected typo in RewriteRule above.
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby PCGUY112887 » Mon Oct 14, 2013 9:02 pm

Thanks for the quick reply!

By the "old seo" I mean my old seo setup for my phpBB2 forum. I do not remember if it was this one or another... I'm thinking another.

I tried adding your line, but unfortunately it started spitting 500 errors over the entire website. Here is the log.

[Mon Oct 14 15:59:34.531350 2013] [core:alert] [pid 15594] [client xxxxx] /myserverpath/public_html/.htaccess: RewriteRule: cannot compile regular expression '^viewtopic\\,p\\,([0-9]+)\\.html)$'
PCGUY112887
 
Posts: 4
Joined: Mon Oct 14, 2013 6:58 pm

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby PCGUY112887 » Tue Oct 15, 2013 12:03 am

This may help... it's my current .htaccess

I also have Zero Dupe turned on and set to Strict.

I believe I'd want to make this redirect 301, correct? Since it's my old URL... or is it already 301 since it has to rewrite the URL to the normal viewtopic format then it gets 301'ed by phpBB SEO & Zero Dupe?

Code: Select all
# Lines That should already be in your .htacess
<Files "config.php">
   Order Allow,Deny
   Deny from All
</Files>
<Files "common.php">
   Order Allow,Deny
   Deny from All
</Files>

DirectoryIndex portal.php index.php index.html index.htm

Options -Indexes

# You may need to un-comment the following lines
# Options +FollowSymlinks
# To make sure that rewritten dir or file (/|.html) will not load dir.php in case it exist
# Options -MultiViews
# REMEBER YOU ONLY NEED TO STARD MOD REWRITE ONCE
RewriteEngine On
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
# RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
# REWRITE BASE
RewriteBase /
# HERE IS A GOOD PLACE TO FORCE CANONICAL DOMAIN
RewriteCond %{HTTP_HOST} !^www\.spudfiles\.com$ [NC]
RewriteRule ^(.*)$ http://www.spudfiles.com/$1 [QSA,L,R=301]
RewriteRule ^portal\.php/(.+)$ /$1 [R,L]
RewriteRule ^portal\.php/?$ / [R,L]

#####################################################
# More rewrites (not genearted from the SEO mod)
#####################################################
RewriteCond %{HTTP_HOST} ^spudfiles\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.spudfiles\.com$
RewriteRule ^profile\.php$ "http\:\/\/www\.spudfiles\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} ^spudfiles\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.spudfiles\.com$
RewriteRule ^pvc_pipe_info\.php$ "http\:\/\/www\.spudfiles\.com\/materials\-ammo\/pvc\-pipe\-size\-info\-t25419\.html" [R=301,L]
#####################################################
# END additional rewrites
#####################################################

# DO NOT GO FURTHER IF THE REQUESTED FILE / DIR DOES EXISTS
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
#####################################################
# PHPBB SEO REWRITE RULES ALL MODES
#####################################################
# AUTHOR : dcz www.phpbb-seo.com
# STARTED : 01/2006
#################################
# FORUMS PAGES
###############
# FORUM INDEX
RewriteRule ^forum\.html$ /index.php [QSA,L,NC]
# FORUM ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/?(page([0-9]+)\.html)?$ /viewforum.php?f=$2&start=$4 [QSA,L,NC]
# TOPIC WITH VIRTUAL FOLDER ALL MODES
RewriteRule ^(forum|[a-z0-9_-]*-f)([0-9]+)/(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?f=$2&t=$4&start=$6 [QSA,L,NC]
# TOPIC WITHOUT FORUM ID & DELIM ALL MODES
RewriteRule ^([a-z0-9_-]*)/?(topic|[a-z0-9_-]*-t)([0-9]+)(-([0-9]+))?\.html$ /viewtopic.php?forum_uri=$1&t=$3&start=$5 [QSA,L,NC]
# PHPBB FILES ALL MODES
RewriteRule ^resources/[a-z0-9_-]+/(thumb/)?([0-9]+)$ /download/file.php?id=$2&t=$1 [QSA,L,NC]
# PROFILES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)/?$ /memberlist.php?mode=viewprofile&u=$2 [QSA,L,NC]
# USER MESSAGES ALL MODES WITH ID
RewriteRule ^(member|[a-z0-9_-]*-u)([0-9]+)/(topics|posts)/?(page([0-9]+)\.html)?$ /search.php?author_id=$2&sr=$3&start=$5 [QSA,L,NC]
# GROUPS ALL MODES
RewriteRule ^(group|[a-z0-9_-]*-g)([0-9]+)(-([0-9]+))?\.html$ /memberlist.php?mode=group&g=$2&start=$4 [QSA,L,NC]
# POST
RewriteRule ^post([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]
# ACTIVE TOPICS
RewriteRule ^active-topics(-([0-9]+))?\.html$ /search.php?search_id=active_topics&start=$2&sr=topics [QSA,L,NC]
# UNANSWERED TOPICS
RewriteRule ^unanswered(-([0-9]+))?\.html$ /search.php?search_id=unanswered&start=$2&sr=topics [QSA,L,NC]
# NEW POSTS
RewriteRule ^newposts(-([0-9]+))?\.html$ /search.php?search_id=newposts&start=$2&sr=topics [QSA,L,NC]
# UNREAD POSTS
RewriteRule ^unreadposts(-([0-9]+))?\.html$ /search.php?search_id=unreadposts&start=$2 [QSA,L,NC]
# THE TEAM
RewriteRule ^the-team\.html$ /memberlist.php?mode=leaders [QSA,L,NC]
# HERE IS A GOOD PLACE TO ADD OTHER PHPBB RELATED REWRITERULES

# FORUM WITHOUT ID & DELIM ALL MODES
# THESE THREE LINES MUST BE LOCATED AT THE END OF YOUR HTACCESS TO WORK PROPERLY
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9_-]+)/?(page([0-9]+)\.html)?$ /viewforum.php?forum_uri=$1&start=$3 [QSA,L,NC]
# FIX RELATIVE PATHS : FILES
RewriteRule ^.+/(style\.php|ucp\.php|mcp\.php|faq\.php|download/file.php)$ /$1 [QSA,L,NC,R=301]
# FIX RELATIVE PATHS : IMAGES
RewriteRule ^.+/(styles/.*|images/.*)/$ /$1 [QSA,L,NC,R=301]
# END PHPBB PAGES
#####################################################
PCGUY112887
 
Posts: 4
Joined: Mon Oct 14, 2013 6:58 pm

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby HB » Tue Oct 15, 2013 2:02 pm

PCGUY112887 wrote:I tried adding your line, but unfortunately it started spitting 500 errors over the entire website.'

You should test on a local server; see How to set up a local server using xampp for step-by-step instructions. Back to your error, it looks like there's an extra ")" at the end.

Code: Select all
RewriteRule ^viewtopic\,p\,([0-9]+)\.html$ /viewtopic.php?p=$1 [QSA,L,NC]


Please note that I did not test this. Please set up a local test environment and verify it works as expected before going live.

PCGUY112887 wrote:I believe I'd want to make this redirect 301, correct? Since it's my old URL... or is it already 301 since it has to rewrite the URL to the normal viewtopic format then it gets 301'ed by phpBB SEO & Zero Dupe?

The rule above rewrites your "old" format to the standard phpBB format; that will get 301'd to the final URL format thanks to the Zero Dupe. To see this more clearly, try http://web-sniffer.net/ -- it shows you the return headers your browser would receive. So, to review, browser requests "old" URL... viewtopic.php responds with 301 to canonical URL. Browser follows 301 request using the canonical URL; viewtopic.php again gets a request, this time using the canonical URL, so it returns the content and 200. End of story.
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby PCGUY112887 » Tue Oct 15, 2013 11:32 pm

Hello,

Thank you so much for the help! It seems to direct most URL's as I need!

I wasn't testing this on my local server since .htaccess doesn't rewrite properly since my address is it's IP instead of it's actual domain name. I guess I could modify my hosts file to fix this, or change everything to my test server IP on my test site... but not totally sure if it's worth it. The 500 errors were only displaying for a moment, when I modify things live I test quickly :D
PCGUY112887
 
Posts: 4
Joined: Mon Oct 14, 2013 6:58 pm

Re: Migrating from phpbb2 & old SEO - URL troubles

Postby HB » Wed Oct 16, 2013 1:46 pm

Last tip... When testing locally, I add an entry in the hosts file (e.g., 127.0.0.1 www.spud.com) and then update the server_name row in the phpbb_config table to match it. Then I can test locally using one name (www.spud.com) and compare it against the live site (www.spudfiles.com). Of course the .htaccess will need both patterns to match (www.spud.com and spudfiles.com), but there are very few TLD entries in most .htaccess since most pattern matches are relative to the root.
Dan Kehn
HB
phpBB SEO Team
phpBB SEO Team
 
Posts: 1509
Joined: Mon Oct 16, 2006 2:25 am


Return to phpBB Forum

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 48 guests


 
cron