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 not working when an entry exists #391

Closed
kevinmu17 opened this issue Feb 23, 2022 · 5 comments
Closed

Redirect not working when an entry exists #391

kevinmu17 opened this issue Feb 23, 2022 · 5 comments

Comments

@kevinmu17
Copy link

Description

I'm trying to add some redirects for a client but they do not work.

When doing something simple like 'test' > 'test2' it is working absolutely fine. But when trying to redirect an URI while an entry exists on that URI the redirect doesn't do a thing. Is this by design?

Steps to reproduce

  1. create a single entry like 'notworking'
  2. Add SEO redirect '/notworking' to '/notworking2'

Additional info

  • Craft version: 3.7.34
  • SEO version: 3.7.4
  • PHP version: 8.0.13
  • Database driver & version: MariaDB 10.3
  • Other Plugins: N/A
@hadyfarhat97
Copy link

Same here.

When I enter a URI that's associated with an entry, the redirect doesn't work. However, when I enter a random URI that's no associated with an entry, the redirect works

@masiorama
Copy link

Same here. +1

@alexjcollins
Copy link
Member

That is the intended behaviour - we only run a lookup in the redirects table when Craft returns a 404.
The idea behind this is to remove the need to query the redirects on every request.

It's possible to use {% exit 404 %} in templates to force a redirect. Changlog.

@masiorama
Copy link

@alexjcollins I see, so in order to fix it a solution could be this, on top of the template, right?

{% if (craft.app.request.getSegment(1) == 'oldurl')%}
    {% exit 404 %}
{% endif %}

Thanks

@alexjcollins
Copy link
Member

Yeah, exactly 👍

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

4 participants