Site folder structure setup


Starting from scratch…

On my web host I have something like:


This is the location where I want to put one website that is managed by Surreal. Within the above folder (which is the root for the website) I want to conceptually have the following structure:

/assets/ - things like style sheets. Content editors don’t need to know about this folder and shouldn’t see it.
/pages/ - pages that content editors are allowed to see and edit
/uploads/ - area where content editors can upload files

First problem: in v7, the uploads folder may not be outside of the pages folder. Workaround:


Don’t like it, but it will have to do unless Surreal allows the uploads folder to sit outside of the home folder.

Second issue - in order for a web browser to serve up my homepage (let’s call it ‘homepage.html’) using the URL:

I need a rewrite rule in place to serve up that page from the /pages/ subfolder (without showing that subfolder in the address bar).

I have:

RewriteEngine on
DirectoryIndex pages/homepage.html

<IfModule mod_rewrite.c>
   Options +FollowSymLinks
   Options +Indexes
   RewriteEngine On
   RewriteBase /

   # Rewrites all URLS without blog in them
   RewriteCond %{REQUEST_URI} !^/pages/

   # Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
   RewriteCond %{HTTP_HOST} ^(www\.)?\.

   # Rewrite all those to insert /folder
   RewriteRule ^(.*)$ /pages/$1 [L]

Now the web browser works as I hope - it shows me the homepage content whilst leaving the address bar with just the domain name in it, but…

Problem 2: Whilst editing that site in Surreal, I can see that homepage listed, but when I click on it to edit I get:

# Sorry, this page doesn't exist.
Please check the URL or go back a page.

## 404 Error. Page Not Found.

How to resolve?


You may be overcomplicating things here. Rewrites like that won’t work because Surreal maps the URL to the file system.

Version 7 was designed to be more foolproof than previous versions so you can have a very basic structure like this:


If you point your uploads folder to uploads/ then users will only be able to upload/delete files inside the uploads/ folder.

When browsing for pages, they’ll see a flat list of pages, not the file system:

In fact, the only time they’ll be able to see the contents of the home folder (i.e. the root directory) is when they create a new page, but they won’t be able to upload/delete anything there — it’s just to select a folder.