Custom route ignore few url from discourse

AI-generated summary

Custom Route Issue in Discourse

Hitesh_Sharma is experiencing issues with a custom route in Discourse, where specific URLs are not being ignored as expected. The code in the routes.rb file is:

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')}

Hitesh_Sharma explains that the custom route is used to redirect old Drupal URLs to Discourse topics, but the current implementation is blocking some URLs like login and signup.

Canapin asked for more context, and pfaffman suggested using permalink redirects and permalink normalizations instead of custom routes. However, Hitesh_Sharma clarified that permalinks are not being used in their Discourse setup and is seeking help to resolve the issue with their current code.

Hi,

I am trying to ignore specific URLs on this custom route using the code below.
(routes.rb files)

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')}

“It’s not working as expected. Do you have any experience dealing with this issue?”

Hi :slight_smile:

What is the context of what you’re trying to achieve?

hi @Canapin

I am using custom functionality for the Drupal URL topic shown in the discourse
site.

When a user visits the old URL of the Drupal site in a web browser, the system first checks in custom routes. It either ignores certain specified URLs as mentioned in custom routes, or it goes to the ‘custom_redirect’ function. In the ‘custom_redirect’ function, it finds the topic in Discourse and redirects the browser to that link.

If you’re trying to get drupal URLs to 301 to the proper Discourse topic then you want to use permalink redirects and probably permalink normalizations.

If you used an import script, it should have created permalinks, which you can see at /admin/customize/permalinks. If they aren’t working then you can use a permalink normalization to fix them up.

@pfaffman
I am not using permalinks in discourse

My code is working for old site posts URL redirect to discourse topic or posts

But with this code they block some URL like login , signup, other forms

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’)}

You have some idea what I am missing !!