{"id":22963012,"url":"https://github.com/terminal42/contao-url-rewrite","last_synced_at":"2025-04-10T02:27:57.821Z","repository":{"id":23252246,"uuid":"96196028","full_name":"terminal42/contao-url-rewrite","owner":"terminal42","description":"Provides a back end module in Contao that allows you to specify url rewrites that are added to the Symfony Route collection","archived":false,"fork":false,"pushed_at":"2024-11-12T16:29:52.000Z","size":266,"stargazers_count":16,"open_issues_count":4,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-03T00:07:43.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terminal42.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"terminal42","ko_fi":"terminal42"}},"created_at":"2017-07-04T08:43:56.000Z","updated_at":"2025-03-29T22:03:14.000Z","dependencies_parsed_at":"2025-01-09T17:42:13.656Z","dependency_job_id":"2ca409e2-11d0-4e49-9897-2edfd64e2c83","html_url":"https://github.com/terminal42/contao-url-rewrite","commit_stats":{"total_commits":136,"total_committers":6,"mean_commits":"22.666666666666668","dds":0.3161764705882353,"last_synced_commit":"0b4d1b97f546c48dfb408c5f8ea2d0d8bd3d2ebb"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminal42%2Fcontao-url-rewrite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminal42%2Fcontao-url-rewrite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminal42%2Fcontao-url-rewrite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terminal42%2Fcontao-url-rewrite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terminal42","download_url":"https://codeload.github.com/terminal42/contao-url-rewrite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248143896,"owners_count":21054840,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T19:19:49.451Z","updated_at":"2025-04-10T02:27:57.791Z","avatar_url":"https://github.com/terminal42.png","language":"PHP","funding_links":["https://github.com/sponsors/terminal42","https://ko-fi.com/terminal42"],"categories":[],"sub_categories":[],"readme":"# URL Rewrite bundle for Contao Open Source CMS\n\nThe extension provides a new way for Contao to set various URL rewrites. The available config providers are:\n\n- Bundle config provider – the entries are taken from `config.yml` file\n- Database provider – the entries are taken from backend module\n\nBehind the scenes the rules are added as routes to the internal application router which allows to use all the features\nprovided by the Symfony Routing component.\n\n## Installation\n\nInstall the bundle via Composer:\n\n```\ncomposer require terminal42/contao-url-rewrite\n```\n\n## Migration of short URLs\n\nSince the extension [fritzmg/contao-short-urls](https://packagist.org/packages/fritzmg/contao-short-urls) has been\nabandoned, you can migrate short URLs to URL rewrites with the extension \n[bwein-net/contao-migrate-short-urls](https://packagist.org/packages/bwein-net/contao-migrate-short-urls).\n\n## Configuration\n\n### Bundle configuration\n\nThe bundle configuration is optional. Here you can define the entries and disable the backend management module.\n\n**Note:** if you want to use the `%` character, make sure it is properly escaped by doubling it `%%`.\n\n```yaml\n# config/config.yml\nterminal42_url_rewrite:\n    backend_management: false # Disable backend management of entries (true by default)\n    entries: # Optional entries\n        -\n            request: { path: 'find/{address}' }\n            response: { code: 303, uri: 'https://www.google.com/maps?q={address}' }\n\n        -\n            request:\n                path: 'news/{news}'\n                requirements: {news: '\\d+'}\n            response:\n                code: 301\n                uri: '{{news_url::{news}|absolute}}'\n\n        -\n            request:\n                path: 'home.php'\n                hosts: ['localhost']\n                condition: \"context.getMethod() == 'GET' and request.query.has('page')\"\n            response:\n                uri: '{{link_url::{page}|absolute}}'\n```\n\n### Running under non Contao managed edition\n\nIf you are running the Contao Managed Edition then the extension should work out of the box. For all the other systems\nyou have to additionally register the routing configuration in the config files:\n\n```yaml\n# config/routing.yml\nimports:\n  - { resource: '@Terminal42UrlRewriteBundle/Resources/config/routing.yml' }\n```\n\n## Examples\n\n1. Find address on Google Maps:\n\n```\nType: basic\nPath restriction: find/{address}\nResponse code: 303 See Other\nResponse URI: https://www.google.com/maps?q={address}\n---\nResult: domain.tld/find/Switzerland → https://www.google.com/maps?q=Switzerland\n```\n\n2. Redirect to a specific news entry:\n\n```\nType: basic\nPath restriction: news/{news}\nRequirements: [news =\u003e \\d+]\nResponse code: 301 Moved Permanently\nResponse URI: {{news_url::{news}|absolute}}\n---\nResult: domain.tld/news/123 → domain.tld/news-reader/foobar-123.html\nResult: domain.tld/news/foobar → 404 Page Not Found\n```\n\n3. Rewrite legacy URLs with query string:\n\n```\nType: expert\nPath restriction: home.php\nRequest condition: context.getMethod() == 'GET' and request.query.has('page')\nResponse code: 301 Moved Permanently\nResponse URI: {{link_url::{page}|absolute}}\n---\nResult: domain.tld/home.php?page=123 → domain.tld/foobar-123.html\n```\n\n4. Rewrite URLs including slashes (without query string) to new domain:\n\n```\nType: basic\nHosts restriction: [domain.com]\nPath restriction: /{wildcard}\nRequirements: [wildcard =\u003e .*]\nResponse code: 301 Moved Permanently\nResponse redirect URL: https://domain.tld/{wildcard}\n---\nResult: domain.com/blog/test → https://domain.tld/blog/test\n```\n\n## Create a custom config provider\n\nIn addition to the existing providers you can create your own class that provides the rewrite configurations.\nThe new service must implement the [Terminal42\\UrlRewriteBundle\\ConfigProvider\\ConfigProviderInterface](src/ConfigProvider/ConfigProviderInterface.php)\ninterface and be registered with the appropriate tag:\n\n```yaml\nservices:\n    app.my_rewrite_provider:\n        class: AppBundle\\RewriteProvider\\MyRewriteProvider\n        public: false\n        tags:\n            - { name: terminal42_url_rewrite.provider, priority: 128 }\n```\n\n## Resources\n\n1. [Symfony Routing](https://symfony.com/doc/current/routing.html)\n2. [Symfony Routing Component](https://symfony.com/doc/current/components/routing.html)\n3. [How to Restrict Route Matching through Conditions](https://symfony.com/doc/current/routing/conditions.html)\n4. [How to Define Route Requirements](https://symfony.com/doc/current/routing/requirements.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterminal42%2Fcontao-url-rewrite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterminal42%2Fcontao-url-rewrite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterminal42%2Fcontao-url-rewrite/lists"}