# Non-permalink normalizations

**URL:** https://meta.discourse.org/t/non-permalink-normalizations/62467
**Category:** Development
**Created:** [May 10, 2017, 10:27pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467 "2017-05-10T22:27:53Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 10, 2017, 10:27pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/1 "2017-05-10T22:27:53Z")

</div>

Should `permalink normalizations` work for non-permalinks?

I’m working on a Ning import.

Links look like this:

```
http://localhost:3000/forum/topics/ancillary-probate-procedure-oklahoma

```

This link works fine (the slugs match)

```
http://localhost:3000/t/ancillary-probate-procedure-oklahoma

```

If I create a permalink for /topics/ancillary-probate-procedure-oklahoma and then a permalink normalization like

```
/forum\/topics\/(.+)/topics/\1

```

It works just fine, but this permalink:

```
/forum\/topics\/(.+)/t/\1

```

seems like it should redirect to the built-in Discourse URL, but doesn’t.

Do I need to create permalinks for all of those slugs when Discourse could just match them up itself?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2017, 3:41pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/2 "2017-05-11T15:41:09Z")

</div>

It is hard for me to describe how 😕 I am… and I wrote the code so I should know.

Is there any way you could write some pseudo code of a failing test case that you want addressed?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 11, 2017, 3:49pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/3 "2017-05-11T15:49:19Z")

</div>

Thanks, @sam.

Here’s the deal: It appears that this is what happens:

```plaintext
if url-fails
   apply permalink normalization
   check url against permalinks
  ...

```

What I am proposing is

```plaintext
if url-fails
   apply permalink normalization
   check url against permalinks
   check url against discourse urls

```

For the bulk of these Ning URLs, replacing `/forum/topics/` with `/t/` will make the URLs resolve (at least when Discourse’s title-to-slug code matches Ning’s–Ning doesn’t provide the slugs it generates). Right now, it looks like I’ll need to do something like create permalinks at /forum/topics/slug.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 11, 2017, 3:54pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/4 "2017-05-11T15:54:38Z")

</div>

I see, yeah this can possibly change this but it would amend the pipeline of permalink controller quite a bit.

But… you already have all the slugs, what is the problem with creating the records in the permalink table via the importer?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 11, 2017, 3:57pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/5 "2017-05-11T15:57:16Z")

</div>

> [@sam](#):
>
> it would amend the pipeline of permalink controller quite a bit.

I see. Then it’s not worth it.

> [@sam](#):
>
> what is the problem with creating the records in the permalink table via the importer?

It’s just that creating the permalinks is harder than not creating them. 🙂

My real problem is that it took me all day yesterday to figure this out. ☹

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 11, 2017, 4:01pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/6 "2017-05-11T16:01:53Z")

</div>

Is this another case where a customer wants a Discourse forum at the exact same URL as the previous software forum? These are technically much more complicated.

I strongly recommend _not_ letting customers do that, unless they pay extra.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 11, 2017, 4:05pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/7 "2017-05-11T16:05:23Z")

</div>

So you’d put discourse at [forum.domain.com](http://forum.domain.com) and have [www.domain.com](http://www.domain.com) do those redirects of `/forum/topics/(.*)` to `forum.domain.com/t/\1`? He doesn’t necessarily care where the forum lives, just that his thousands of organic search hits don’t become 404s.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 11, 2017, 4:08pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/8 "2017-05-11T16:08:35Z")

</div>

Yes, exactly. Having this at another subdomain makes it easier in our experience. You still need a lookup table from old URL to new URL in any case but plenty of instructions on how to do this using nginx, apache, etc out there.

That basically takes you out of the realm of “Discourse specific” to “anyone who has ever run a website on any software ever has run into this and solved it before” territory. It makes it into a general problem rather than a specific one and thus… easier to solve, yes?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 11, 2017, 4:13pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/9 "2017-05-11T16:13:53Z")

</div>

Perhaps. The other side is that it’s easier to have one web server in place than more than one. And in this particular case, where the concern is search engine traffic rather than links from other places, it won’t matter at all after Google re-indexes the new site.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 11, 2017, 4:14pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/10 "2017-05-11T16:14:39Z")

</div>

It will matter forever for any external links on the web to this content, though.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 11, 2017, 4:17pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/11 "2017-05-11T16:17:51Z")

</div>

Right. He doesn’t think that there are many such links for his community, though. It’s just search engines that he cares about. But perhaps the redirect is simple enough that I can configure SquareSpace to do the redirects with just a few rules.

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [May 11, 2017, 4:40pm UTC](https://meta.discourse.org/t/non-permalink-normalizations/62467/12 "2017-05-11T16:40:16Z")

</div>

> [@pfaffman](#):
>
> The other side is that it’s easier to have one web server in place than more than one

You can get this with one webserver, using nginx server blocks.
