# URL 重定向不再总是首次生效

**URL:** https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277
**Category:** Support
**Created:** [2018年十一月5日 00:12 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277 "2018-11-05T00:12:23Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [2018年十一月5日 00:12 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/1 "2018-11-05T00:12:23Z")

</div>

Our forum was converted from phpBB, with the importer creating a big table of URL redirects to keep all the old links working, which was much appreciated.

For example:

- `https://resource.dopus.com/viewtopic.php?t=4791`

Redirects to:

- `https://resource.dopus.com/t/how-to-exit-directory-opus/3479`

That worked well for about a year but in the last few months or so we’ve noticed that the first time you click on a redirect URL, you sometimes get Discourse’s “oops! that page doesn’t exist” error page.

The weird thing is, the redirects are not missing or broken, they actually do work, if you click the browser’s Refresh button when on that error page. Once you’ve done that once, the redirect URL then works fine (at least on the same computer).

I couldn’t find any other threads about this so I wonder if it’s something that has gone wrong with our forum, or maybe a plugin we’re using. Or is this a known issue? Any idea how to debug it, or what might be causing it?

* * *

Aside:

Those redirects are still important to us, even now, since we have some external links and also quite a few posts on the forum still use the old URLs to link to each other. (At least at the time, the importer converted links in posts to the new format, but only if a later post linked to an earlier post; some posts had links to posts newer them themselves via edits, which remained in the old URL format, since the importer could only create redirects to topics that had already been converted when converting each topic. Our FAQs section in particular has a lot of crosslinking.)

---

<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: [2018年十一月5日 03:02 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/2 "2018-11-05T03:02:59Z")

</div>

> [@LeoDavidson](#):
>
> [How to Exit Directory Opus - Opus FAQs - Directory Opus Resource Centre](https://resource.dopus.com/viewtopic.php?t=4791)

This worked fine for me in mobile safari, first time.

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [2018年十一月5日 03:09 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/3 "2018-11-05T03:09:51Z")

</div>

I’m not sure if external redirects fail, or only ones when you’re already in a post and the site links to itself. (Maybe the JavaScript side gets confused?)

Or it’s also possible that once someone does a browser refresh on the error page it fixes the redirect for everyone. Hard to tell.

Seems odd that the behaviour of a URL can change just from a refresh, but I figure the JavaScript app intercepts and handles clicks within the site quite differently to the browser expliciltly requesting a page/URL, so maybe the problem is there somewhere.

Next time it happens I’ll experiment with other computers/browsers.

Sounds like it isn’t a known issue, at least. I’ll post back if I find anything that might be useful.

---

<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: [2018年十一月5日 03:22 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/4 "2018-11-05T03:22:19Z")

</div>

Internal links will be a nightmare because you have copied the domain exactly in your migration from old to new forum. We do not recommend that.

---

<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: [2018年十一月5日 04:55 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/5 "2018-11-05T04:55:44Z")

</div>

Permalinks don’t work internally. The URLs need to be rewritten with the discourse URLs.

---

<div class="post-metadata">

### Author: ![LeoDavidson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leodavidson/32/119574_2.png) [@LeoDavidson](https://meta.discourse.org/u/LeoDavidson)
#### Post date: [2018年十一月5日 11:24 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/6 "2018-11-05T11:24:52Z")

</div>

I could swear they used to. Maybe we just never noticed it until more recently.

In that case the problem with the phpBB importer where it cannot rewrite URLs to newer posts than the one it is currently converting is a bug rather than just a minor annoyance. Assuming that is still the same. (I have not done another phpBB import since the original one so maybe it’s already fixed.)

I’ll do a search on my forum and edit anything which still links to the old style URLs. Case closed!

---

<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: [2018年十一月5日 12:49 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/7 "2018-11-05T12:49:09Z")

</div>

> [@LeoDavidson](#):
>
> importer where it cannot rewrite URLs to newer posts than the one it is currently converting is a bug rather than just a minor annoyance.

I’ve not looked at the code, but I think that several that do those rewrites assume that people won’t link to the future. But if you have long lasting topics then that could happen a lot.

It’s probably possible to run code to do those replacements now from the console

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2018年十二月5日 12:49 UTC](https://meta.discourse.org/t/url-redirects-no-longer-always-work-the-first-time/101277/8 "2018-12-05T12:49:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
