-
-
Notifications
You must be signed in to change notification settings - Fork 511
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
give the ability to choose the redirect type (ex: 301) to improve SEO. #881
Comments
Upvote! This makes sense! @ZakariaTlilani I have a workaround for this: $url = $request->fullUrl(); $appUrl = Env::get('APP_URL'); if (Str::startsWith($path, "/de/")) { Whereas "/de/" is my default locale. But of course a proper solution would be great! Like a config param to set the HTTP code. |
@petrosit yes, this seems one of the good solutions. |
The package uses 302 by default.
|
Thank you for your suggestion! You’ve raised an important point about the impact of 302 redirects on SEO when hideDefaultLocaleInURL is enabled. However, changing all 302 redirects to 301 could lead to problems. For example, session-based redirects (like those from LocaleSessionRedirect) depend on the user’s session, which can vary dynamically. Using a 301 redirect here would be inappropriate, as it signals a permanent change, potentially misleading search engines. A 302 redirect is more suitable for such scenarios. In cases like hiding the default locale (e.g., redirecting /en/ to /), a 301 might make sense. However, this could cause issues if the default language changes later, as search engines will cache the 301 permanently. A configuration option like use 301 when appropriate could provide flexibility while ensuring session-based redirects remain 302. This is a nuanced issue that requires careful handling to balance SEO with dynamic behaviors. Thank you again for raising this—I’ll review it further or welcome a pull request for discussion! |
Is your feature request related to a problem? Please describe.
yes, it is.
When choosing to activate 'hideDefaultLocaleInURL' which removes the default locale short name in the URL (ex: /fr ) and while having a 302 redirect hard coded that means all link are "temporary redirect", the entire website has a duplicate (according to the crawlers -ex: google), which is very harmfull to the websites SEO. the bigger the website the worst the issue gets.
Describe the solution you'd like
i think what would be best is to simply allow the coder to choose by setting another variable in config file.
The text was updated successfully, but these errors were encountered: