D
D
Dmitry Filandor2016-11-02 15:42:29
Search Engine Optimization
Dmitry Filandor, 2016-11-02 15:42:29

How to change the route?

Hello!
The standard route in asp is as follows:

routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );

In order to avoid unnecessary nesting and remove home in the actions of the Home controller on the main pages (about the site, contacts), etc., I write above this route:
routes.MapRoute(
               "HomeContact",
               "contact",
               new { controller = "Home", action = "Contact" }
           );

now I have a beautiful url site/Contact instead of site/home/Contact
found a problem in terms of SEO - my page is available on both routes - site/Contact and site/home/Contact
are duplicates. How to do it more correctly and gracefully? I don’t feel like writing a 301 redirect in web.config for every page. Not only do I add a route to each page in RoutConfig, but also now redirects ....
if I understand the canonical tag correctly, then I need to add on duplicate pages (site/home/Contact)
<link rel="canonical" href="http://site/Contact" />

but a seasoned familiar seoshnik says correctly 301 redirect ...
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2016-11-02
@LifeAct

rel="canonical" is correct no redirects! To simplify working with all this, I recommend using mvcsitemapprovider , specifically for SEO, read here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question