-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Enforcing Trailing slash or not routes #1807
Comments
Agree that it's better behavior but don't agree that it has any impact on SEO. |
Well, it would affect SEO if a route returned 200 on both trailing slash and without and it serves the same content. You'll get duplicate content issues. http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html |
@rclai yes, but it's not the case with Yii2. |
okay cool |
May i make these? |
Yes, feel free to make a pull request. |
These "slashes or not" should be written in the routes? For example:
Or how they should be configured? One general parameter for the UrlManager component? |
Hmm... good question @yiisoft/core-developers what do you think? |
I think this issue is about automatically performing 301 redirection. We use |
@qiangxue uh, ok, sorry. Yes, it's definitely enough. Then there is no more questions |
So should we redirect from unsuffixed URL to suffixed URL? What about redirecting from |
Either direction is possible. There should be an option at manager and rule levels that toggle this behavior. |
I agree with the above that it affects the SEO. We should make sure that
Above solution is the most preferred in the SEO based url. |
@dilip-vishwa it does not affect SEO for the reasons I've stated above. |
You stated reasons? But anyway, it doesn't matter, like @qiangxue said, just as long as we can get an option manager and rule levels to toggle the behavior. |
@rclai confused with another pull-request where I did. Here's the explaination from Google: http://googlewebmastercentral.blogspot.ru/2010/04/to-slash-or-not-to-slash.html No duplicate content — no problem. There's no difference between Anyway, current plan is good. |
But if user don't use trailing slash, then they will get 404 error which is not good for the business. |
@dilip-vishwa Need trailing slash — use
Absolutelly meaningless. Yii should not act like this. This is about configuration. |
@creocoder OK |
Ok, soo what should i do? Will be there redirection or it is for web server? |
I am for configurable redirect on framework side. |
@samdark I'm against. This is web server task. For apache this can be achived through |
Thought about it a bit more and @creocoder may be right about it. |
I can understand the issue with the trailing slash when using slugs or actions.
So I have to add only for the trailing slash an additional url rule, where the suffix is set.
That way all possibilities can be set and on parseRequest there is then also a check if pathInfo has the optional_suffix added. This issue is I guess somehow strange because without custom rules you will get the handling that controllername/ would call the index action. But with custom rules you will have to add an additional rule to have this to be able to set something like this (?:[/])? samdark has written in my issue: But then why it is possible to call site/ and get the index action instead of a 404 with no custom url rules. |
So now we need redirect one of them to other? right? domain.com/item/10/item-slug TO domain.com/item/10/item-slug/ |
see #7670 it has some solutions. |
I think it is paramount that routes enforce a trailing slash or not, in the sense that if I configure my routes to have a trailing slash, and I access the URL without the slash, that it should 301 to the one with a trailing slash. Same thing if I configure it not to have a trailing slash, that it would 301 a request with a trailing slash to the one without it.
This is important for SEO.
The text was updated successfully, but these errors were encountered: