# カスタムルートはdiscourseからいくつかのURLを無視します

**URL:** https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405
**Category:** Development
**Created:** [2023 年 10 月 25 日午後 12:57 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405 "2023-10-25T12:57:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Hitesh\_Sharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hitesh_sharma/32/309992_2.png) [@Hitesh\_Sharma](https://meta.discourse.org/u/Hitesh_Sharma)
#### Post date: [2023 年 10 月 25 日午後 12:57 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405/1 "2023-10-25T12:57:08Z")

</div>

こんにちは。

以下のコードを使用して、このカスタムルートで特定のURLを無視しようとしています。  
(routes.rb ファイル)

`get '/*path' => 'static#custom_redirect', constraints: lambda { |request| !request.path.include?('/preferences/' ) || !request.path.include?('/custom_sso_login/') || !request.path.include?('/t/' ) || !request.path.include?('/admin/') || !request.path.include?('/singup') || !request.path.include?('/login')}`

「期待どおりに動作しません。この問題に対処した経験はありますか？」

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2023 年 10 月 25 日午後 1:13 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405/3 "2023-10-25T13:13:25Z")

</div>

こんにちは 🙂

達成しようとしていることの文脈は何ですか？

---

<div class="post-metadata">

### Author: ![Hitesh\_Sharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hitesh_sharma/32/309992_2.png) [@Hitesh\_Sharma](https://meta.discourse.org/u/Hitesh_Sharma)
#### Post date: [2023 年 10 月 25 日午後 1:32 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405/4 "2023-10-25T13:32:51Z")

</div>

hi @Canapin

Discourseサイトに表示されているDrupal URLトピックのカスタム機能を使用しています。

ユーザーがブラウザでDrupalサイトの古いURLにアクセスすると、システムはまずカスタムルートをチェックします。カスタムルートで指定された特定のURLを無視するか、'custom\_redirect’関数に移動します。'custom\_redirect’関数で、Discourse内のトピックを見つけ、ブラウザをそのリンクにリダイレクトします。

---

<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: [2023 年 10 月 25 日午後 4:18 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405/6 "2023-10-25T16:18:52Z")

</div>

DrupalのURLを適切なDiscourseトピックに301リダイレクトさせたい場合は、`permalink redirects`と、おそらく`permalink normalizations`を使用すると良いでしょう。

インポートスクリプトを使用した場合は、パーマリンクが作成されているはずです。これは`/admin/customize/permalinks`で確認できます。機能していない場合は、パーマリンク正規化を使用して修正できます。

---

<div class="post-metadata">

### Author: ![Hitesh\_Sharma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hitesh_sharma/32/309992_2.png) [@Hitesh\_Sharma](https://meta.discourse.org/u/Hitesh_Sharma)
#### Post date: [2023 年 10 月 27 日午前 10:28 UTC](https://meta.discourse.org/t/custom-route-ignore-few-url-from-discourse/283405/7 "2023-10-27T10:28:47Z")

</div>

@pfaffman  
ディスコースでパーマリンクを使用していません。

私のコードは、古いサイトの投稿URLをディスコースのトピックまたは投稿にリダイレクトするために機能しています。

しかし、このコードでは、ログイン、サインアップ、その他のフォームなどのURLがブロックされます。

get ‘/\*path’ =\> ‘static#custom\_redirect’, constraints: lambda { |request| !request.path.include?(‘/preferences/’ ) || !request.path.include?(‘/custom\_sso\_login/’) || !request.path.include?(‘/t/’ ) || !request.path.include?(‘/admin/’) || !request.path.include?(‘/singup’) || !request.path.include?(‘/login’)}

何か見落としている点について、何かアイデアはありますか？
