Task #86585

Configurability of page routing

Added by Daniel Dorndorf about 2 years ago. Updated 7 months ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2018-10-06
Due date:
% Done:

0%

TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Sprint Focus:

Description

If I wanted to use .html as url prefix I had to extend the default page decorator

On rootpages it would generate /index.html else.

PageTypeSuffix:
  type: CustomPageType
  default: '.html'
  index: 'index'
  map:
    '.html': 0
class CustomPageTypeDecorator extends PageTypeDecorator
{
    public const IGNORE_INDEX = [
        '/index.html',
        '/index/',
    ];

    public const ROUTE_PATH_DELIMITERS = ['.', '-', '_', '/'];

    /**
     * @param \TYPO3\CMS\Core\Routing\RouteCollection $collection
     * @param array $parameters
     */
    public function decorateForGeneration(RouteCollection $collection, array $parameters): void
    {
        parent::decorateForGeneration($collection, $parameters);

        /**
         * @var string $routeName
         * @var \TYPO3\CMS\Core\Routing\Route $route
         */
        foreach ($collection->all() as $routeName => $route) {
            $path = $route->getPath();

            if (true === \in_array($path, self::IGNORE_INDEX, true)) {
                $route->setPath('/');
            }
        }
    }
}

Related issues

Related to TYPO3 Core - Task #86887: Enable urls like `https://example.com/` and `https://example.com/path/to/site.html`, so only `.html` suffix for page type 0 if there is a path. New 2018-11-08

History

#1 Updated by Riccardo De Contardi about 2 years ago

  • Category set to Link Handling, Site Handling & Routing

#2 Updated by Jan Kornblum almost 2 years ago

Really important for me, too.

#3 Updated by Benni Mack over 1 year ago

  • Status changed from New to Needs Feedback

Hi Daniel,

can you clarify again what exactly the issue is?

Your root page should be `/index.html`, but the others `/subpage.html`?

#4 Updated by Daniel Dorndorf over 1 year ago

Hi Benni,

no, the issue is that it generates the "/index.html" on the startpage and that it shouldn't, only for the subpages.

Even if ".html" can be neglected for seo nowadays it should be configurable I think.

The code I provided helped me to hack around this issue but I never had it in production.

Greetings
Daniel

#5 Updated by DANIEL Rémy about 1 year ago

I would like to configure an empty index:

  PageTypeSuffix:
    type: PageType
    default: '.html'
    index: ''
    map: []

This would generate:

home: /
subpage: /subpage.html

#6 Updated by DANIEL Rémy 9 months ago

  • Related to Task #86887: Enable urls like `https://example.com/` and `https://example.com/path/to/site.html`, so only `.html` suffix for page type 0 if there is a path. added

#7 Updated by Susanne Moog 7 months ago

  • Status changed from Needs Feedback to Closed

Closed as duplicate of #86887 - please continue there.

Also available in: Atom PDF