This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

shahramatrian
shahramatrian

Hi. I'm migrating an old website mostly made of static pages to OctoberCMS but I wanna keep URLs the same as much as possible. One of the issues is that the old website uses DirectoryIndex successfully and works both with <rest_of_url>/ and <rest_of_url>/index.html but I have to choose one of them. I also know how to use .htaccess to redirect all URLs ending with .html to / but this is not what I want. I just want a user to see the same page by entering <rest_of_url>/ or <rest_of_url>/index.html into the browser and without redirect. Can you please help me?

Last updated

JeffGoldblum
JeffGoldblum

Probably the quickest and easiest way to do this is to just duplicate the page under / and /index.html

shahramatrian
shahramatrian

Thanks, Luke, but what about the maintenance? I always try to avoid duplicates. Isn't there any better idea?

JeffGoldblum
JeffGoldblum

Sure, you could define a route in a custom plugin's routes.php and have it return (new Cms\Classes\Controller)->run('/index.html'); but really it's six of one and half a dozen of another when it comes to maintaining that setup. If you're not really going to be updating the page frequently then you could just live with the duplicated files, or if you'd like to take another approach you could have two pages (one / and one /index.html) that contain nothing but a single partial, and then have the page content actually managed in that partial instead.

There's lots of different ways you could handle this, it's just up to you which approach you want to take.

shahramatrian

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.