Custom page in root path?


#1

Hello,

I want to set a custom HTML/Webapp in the root of my UF site (basically, in the public folder).
Since index.php is already taken by UF, how would I do that?

Notes:

  1. The app itself does not use UF’s features (it’s a standalone React app), it only uses the API.
  2. The app needs to have access to subfolders in the public folder, to get its assets from.

The desired outcome:

So, myufsite.com/ would launch the app
And I would want myufsite.com/admin to go to the login screen for the dashboard.

Any thoughts? Thanks


#2

Depends on your web server; I’ve done this for several projects using Apache. Let me know if you need an example for Apache.


#3

I am on Apache also… however I somehow think this needs to be tackled from within UF’s routing system…


#4

There are a few ways to achieve this, however the complexity is up to you. If it’s just a SPA (single page application), you can just drop it in public/admin and it’ll just work.

If it’s got it own routing and doesn’t use a hash to keep track of it (it’s opt in with React Router) complexity will go up as you’ll need to modify the Apache config.

And to be clear, absolutely nothing in UF needs to be touched to achieve this. Static files are always the first preference, with UF being the fall through case. The only possible exception being index.html, and if it is should just be a matter of updating the Apache config.


#5

It is an SPA and uses React Router indeed.

However, I wanted to put it at the root domain (right in UF’s public folder).

Suppose my domain is: myufsite.com, I want that address to load my app. (and not the UF login screen)


#6

Maybe you could use a subdomain? Might be easier to have them separate (share assets through a symlink if necessary). Otherwise, if you want the SPA to be the main site, put UF inside the SPA (in a subfolder), not the other way around?


#7

Here’s what I used to add a custom package (saml “authentication”) to the root path of my UF application:

<Directory "/srv/www/htdocs/PATH_TO_UF/public">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

SetEnv SIMPLESAMLPHP_CONFIG_DIR /var/simplesamlphp/config  #not relevant for this example but required for the application

Alias /simplesaml /var/simplesamlphp/www  #determine the path to the application

<Directory /var/simplesamlphp/www>
    Require all granted
</Directory>

This made “/” the path to my UF application with the exception of “/simplesaml” (the alias).