Editing .htaccess to set a Pages Extension created page as homepage

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
User avatar
[Dimetrodon]
Registered User
Posts: 473
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era

Editing .htaccess to set a Pages Extension created page as homepage

Post by [Dimetrodon] »

Hello.

I am trying to create a homepage for my site that loads up as the site's actual homepage. It is a Pages Extension created page, with the path being [my url]/site-index

But basically, I want it to be the homepage when someone visits the site's root basically, as opposed to showing the phpBB index page.

I would drop a custom php file and set that file as my homepage in .htaccess and create another style html template for it, but I do not want to have to edit raw html every single time I need to make changes to it. I can, but being able to use BBCode and edit from the ACP is easier.
Avatar by Phoenix-of-Starlight.
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3888
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by Kailey »

I haven't tested this with the latest version of phpBB, but a while ago I remember that you could copy (not move) the .htaccess and app.php files to the site's root directory and edit the $phpbb_root_path variable to your board's path and it would cause the pages extension to not require the board path in the URL.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules
If you have any questions about the rules/customs of this website, feel free to send me a PM.

My little corner of the world | Administrator @ phpBB Modders
User avatar
[Dimetrodon]
Registered User
Posts: 473
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by [Dimetrodon] »

Kailey wrote: Fri Sep 06, 2024 6:16 pm I haven't tested this with the latest version of phpBB, but a while ago I remember that you could copy (not move) the .htaccess and app.php files to the site's root directory and edit the $phpbb_root_path variable to your board's path and it would cause the pages extension to not require the board path in the URL.
Thank you, but I installed phpBB to the root path, so that is not an option for me.

In retrospect, I shouldn't have, but still. It is what I did.
Avatar by Phoenix-of-Starlight.
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by thecoalman »

I don't know if this going to work but you can try DirectoryIndex site-index

DirectoryIndex sets the default file(s) when the request only has trailing slash but it's usually set to index.php, index.html etc.

Additionally I don't know if any phpBB links use only trailing slash.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26833
Joined: Fri Aug 29, 2008 9:49 am

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by Mick »

DirectoryIndex seems to be the way to go imo and I don’t think trailing forward slashes matter one way or the other. I’ve just tested a couple here and on a test board with and without trailing forward slashes with no issues.
  • "The more connected we get the more alone we become” - Kyle Broflovski© 🇬🇧
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6313
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by thecoalman »

The reason I'm not sure it's going to work is because I don't know if it expects a file to exist. DirectoryIndex site-index.php is going to work without question if the file site-index.php exists.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
AbuHossam
Registered User
Posts: 361
Joined: Sun Sep 02, 2018 7:24 am

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by AbuHossam »

Following..
Recent Topics in DB-UK Community – Where Every Passion Finds Its Place.
User avatar
[Dimetrodon]
Registered User
Posts: 473
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by [Dimetrodon] »

Thank you both for the replies, but...
thecoalman wrote: Sat Sep 07, 2024 7:16 am The reason I'm not sure it's going to work is because I don't know if it expects a file to exist.
It does expect a file to exist, unfortunately. Unless there is an obscure command for .htaccess that exists that no one has thought of, I am likely going to have to drop a custom .php file and style template for it as opposed to using the extension. I am NOT going to use a simple redirect page as that would look suspicious and anti-malware products might think the site is hacked.

A bit inconvenient but small potatoes.
Avatar by Phoenix-of-Starlight.
User avatar
NeoDev
Registered User
Posts: 24
Joined: Mon Oct 18, 2021 9:52 pm
Name: Neo

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by NeoDev »

Place in root .htaccess file

Code: Select all

RewriteRule "^$" "/url/to/file" [R]
There is no other (easy) way to do what you want in Apache. I wouldn't worry about it looking suspicious, same site redirects are HTTP 101 and a common everyday occurrence.
Come for the comics, stay for the bad fish puns.
— The Cross Time Cafe
User avatar
[Dimetrodon]
Registered User
Posts: 473
Joined: Tue Aug 30, 2022 3:29 am
Location: Paleozoic Era

Re: Editing .htaccess to set a Pages Extension created page as homepage

Post by [Dimetrodon] »

Thank you, but I cannot use this to redirect to a Pages Extension related page.

I'm just going to drop a custom home.php file in my root directory, its style template in the prosilver folder, and then add something like this to .htaccess

Code: Select all

#Alternate default index pages
DirectoryIndex home.php index.php index.htm index.html
So my new file becomes the site's new index page.


I realize what I was trying to originally do with the Pages Extension is impossible with my current setup.
------

Thank you everyone. This can probably be marked as solved.
Avatar by Phoenix-of-Starlight.

Return to “phpBB Custom Coding”