gebeer Posted December 9, 2022 Share Posted December 9, 2022 Hi all, we are moving a site from TYPO3 to PW. The old site has all URLs end in .html. Is there a simple way to achieve this in PW without breaking things like urlSegments, pagination etc. ? It might be doable with a hook to Page::path but I think that will break urlSegments. Maybe instead of trying to achieve that goal it might be better to implement redirects. Has anyone done this before? Would be great to hear your opinions/experiences. 2 Link to comment Share on other sites More sharing options...
ryan Posted December 9, 2022 Share Posted December 9, 2022 @gebeer The period "." is an allowed character in page names, so it's fine to have URLs ending with ".html" ... you would just make the page name end with ".html". You'd probably want to turn off trailing slashes for the templates used by those pages as well. If all URLs end with "index.html" then ProcessWire will take care of those redirects for you automatically, i.e. "/about/index.html" automatically redirects to "/about/" (unless there is literally a page named /about/index.html). If you want to migrate away from using the .html extension, converting things like /about.html to /about/ throughout the site, then it could be done with a redirect rule in the .htaccess file. If you want to have PW respond to either /about.html or /about/ in the same way, then the most direct way might be to add a $_SERVER['REQUEST_URI'] = str_replace('.html', '/', $_SERVER['REQUEST_URI']); at the top of your /index.php file. Though make sure you've got a <link rel="canonical" ... /> tag in your <head> so that search engines don't consider the about.html and /about/ two different URLs. 5 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now