Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect usage / example question #29

Closed
patricksebastien opened this issue Jul 18, 2014 · 4 comments
Closed

redirect usage / example question #29

patricksebastien opened this issue Jul 18, 2014 · 4 comments

Comments

@patricksebastien
Copy link

let's say that my old forum had this category url:
http://forum.com/forum-2-patch

how to have a redirect on my new forum that points to the right url:
http://forum.com/category/2/patch

i see an option in import.config.json for doing this, but not sure how nodebb is handling this? trying to visit http://forum.com/forum-2-patch doesn't redirect me to http://forum.com/category/2/patch - am I missing a step?

@akhoury
Copy link
Owner

akhoury commented Jul 18, 2014

yea, well, you are.

so here's the thing, NodeBB does not redirect anything for you, you need to handle those old URLs yourself. What you can do (what I did) is use a custom proxy, for old links, I built this server tool for this purpose exactly. (there is a link at the bottom of this comment)

However, first you need to configure the import.config.json correctly, using templates, in order for the importer to provide you with a redirect map (sort of) (see the configs here)

so basically, you provide a template for the old link, and the importer will create the new records and spit out a line for each record in the logs (which you can grep and put in a JSON file your self.)

but in your case you're going to need to save some sort of a "_slug" value in your normalized object.
then you change the template accordingly.

  redirectTemplatesStrings: {
        categories: {
            oldPath: '/forum-<%= _id %>-<%= _slug %>', 
            newPath: '/category/<%= cid %>'
        },

then the importer will spit out this in the logs (look for [redirect])
(it's a new id!)

[redirect] "/forum-2-patch":"/category/3",

You grep them, you clean them up from the [redirect] value, you build a valid JSON file out of them, then you use them as a map here https://github.com/akhoury/RedirectBB

@akhoury
Copy link
Owner

akhoury commented Jul 18, 2014

note for your _slug property will most likely be provided somewhere in your PunBB, just add it in your queries and use it in the importer.

@patricksebastien
Copy link
Author

1000x thx!

@akhoury
Copy link
Owner

akhoury commented Jul 18, 2014

also, in my case it was a little easier,

since all my old links where under

example.com/forum*

but my new forum is a subdomain.

forums.example.com

so I had a 2 virtual hosts (using nginx)

main site config, but redirected all the /forum* requests to the RedirectBB process
example.com config: https://github.com/akhoury/RedirectBB/blob/master/nginx.example.com

as for the new forums forums.example.com configs: (which is the usual NodeBB setup)
https://github.com/akhoury/RedirectBB/blob/master/nginx.forums.example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants