Results 1 to 4 of 4

Thread: clean url in news module

  1. #1
    New user
    Join Date
    11-18-12.
    Posts
    24

    Default clean url in news module

    Hi,

    I am currently using Contao 3

    I need to remove "item" in the news URL.

    For example:

    http://mysite.com/news/items/example-news.html

    I want to clean the url to allow the following:

    http://mysite.com/example-news.html

    I appreciate your help.

    Thank you
    Consultor y Formador SEO
    http://www.seosemprofesional.com

  2. #2
    New user
    Join Date
    11-18-12.
    Posts
    24

    Default Re: clean url in news module

    If anyone knows how I can clean the URLs I much appreciate your help

    Thanks
    Consultor y Formador SEO
    http://www.seosemprofesional.com

  3. #3
    New user
    Join Date
    08-26-09.
    Posts
    10

    Default Re: clean url in news module

    Hello,

    There is an option "Enable auto_item" in the "Settings" menu that removes the items/ or events/ part.

    Your URL will be
    http://mysite.com/news/example-news.html
    instead of
    http://mysite.com/news/items/example-news.html

    But I don't know how to get to http://mysite.com/example-news.html, sorry.

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: clean url in news module

    The only way to do the latter is to use a combination of the "generateFrontendUrl" and "getPageIdFromUrl" hooks to rewrite the URLs on the fly, and then direct them to the appropriate place. I believe there are examples already on the forum.

    But this is messy and prone to error. "news/" specifically is very important in helping Contao route requests to the appropriate page. "items/" is also important, but can be removed reliably with the right logic (as it's done in the auto_item parameter mentioned before).

    "/news/items/example-news.html" is interpreted by the system as "/news?items=example-news". That last part is important in telling Contao which news item to display. But the "news" part is equally important in telling Contao which page to display.

    If you remove everything and just have "/example-news.html", how does Contao know how to interpret it? Is "example-news" a page, an article, a news item, an event? Which table does it go to retrieve the appropriate record? And which Object does it instantiate and plug that record into?

    This isn't a problem with some other CMS's out there like Wordpress because they shove ALL of the content into the same table, regardless of what type it is -- a page, post, event, whatever. And big picture wise, that's not a great way to do it for a number of reasons, but it's necessary for how those systems are designed.

    I get into this discussion with my SEO-happy colleague every project, so I wanted to share...
    Brian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •