Reputation: 4053
We have a web site written in ASP.NET. When you open the following page:
You can see the slash "/" at the end. We need to remove it in order to have:
I've tried some things to make it work, but it doesn't help. For example, when I add the following code in Global.asax.cs file:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().Contains("http://concert.local/elki/"))
{
HttpContext.Current.Response.Status = "301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://concert.local/elki/", "http://concert.local/elki"));
}
}
The following error comes up:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
This problem can sometimes be caused by disabling or refusing to accept cookies.
There is also the following code:
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentHead">
<link rel="canonical" href="http://concert.local/elki" />
</asp:Content>
That puts canonical stuff in page header.
How can I get the following URL:
?
Upvotes: 0
Views: 3279
Reputation: 4209
Here is the official answer from Google. Effectively, they dont care whether you have a trailing slash or not http://googlewebmastercentral.blogspot.fr/2010/04/to-slash-or-not-to-slash.html
Google treats each URL above separately (and equally) regardless of whether it’s a file or a directory, or it contains a trailing slash or it doesn’t contain a trailing slash.
Upvotes: 0
Reputation: 8485
Check out this answer: url trailing slash and seo
It basically says that Google prefers the trailing slash. Just code consistently and you should be fine.
Upvotes: 1