Hello,
I got this for the .htaccess translation of the X3 gallery script:
1. Set this environment variable in your Abyss Web Server hostname configuration to an empty value:
HTTP_MOD_REWRITE
Your original htaccess wants it to detect mod_rewrite in Apache.
2. You can hide X3 diagnostics information from visitors by setting this environment variable to 'On':
X3_HIDE_DIAGNOSTICS
Additional environment variables can be added in the interpreter settings where PHP is declared.
3. The X3 htaccess recommends disallowing directory listing, so you should do it.
4. If these file extensions (mime types) don't match these values for your Abyss Web Server host entry where X3 is installed, you need to rectify them to be this:
json:
application/json
js:
application/javascript
svg:
image/svg+xml
webp:
image/webp
mp4:
video/mp4
In the server mimetypes configuration it's not a problem if there's more than one file extension associated to a mimetype.
It's just that each mimetype above needs to atleast have the specified file extensions associated.
For example, application/json needs to have atleast json associated to it.
5. Probably because digital media is already compressed, your X3 script recommends only using gzip compression for the following mimetypes:
- application/javascript
- application/json
- application/xml
- image/svg+xml
- text/css
- text/html
- text/xml
So you could enable compression in Abyss Web Server for your host entry running X3 such that only these mimetypes get compressed when sent to visitors.
6. This X3 script instructs web browsers to disable mimetype-sniffing.
mimetype-sniffing means that web browsers try to determine the file type themselves instead of listening to your server.
You can tell web browsers not to do this by adding this HTTP header in Abyss Web Server for your host running the X3 gallery script:
X-Content-Type-Options
The value needs to be:
nosniff
This extra HTTP response header should be set in your hostname entry's General - Advanced Settings section.
7. While you're in the General - Advanced Settings section of your hostname running the X3 gallery, you can also replicate these file expiry time rules in the original htaccess (labeled 'File Expiration Times'):
text/xml:
0 seconds
Relative to current time
text/xml:
3600 seconds
Relative to current time
application/xml:
3600 seconds
Relative to current time
The 'access' time used in htaccess is equivalent to current time in Abyss Web Server.
8. I personally think that you shouldn't use the default htaccess's 10-years caching period, since if you later want to modify your pictures in the server directory, web browsers theorically would not pick up your modifications until 10 years or when visitors manually clear their web browser cache.
9. Now for what I understood of the htaccess rules:
(you will need to put the x3 folder in the root directory of the host for www
.aurorawings
.me without using aliases)
Rule 1: ---------------
If a request for a file with the extensions html, json, xml, atom or rss is going to point to a non-existing file, then internally redirect the request to a php script without the requested file extension (to find a folder with the same filename).
The trailing slash '/' is used to require a folder instead of a file.
-----------------------
- Relative to base:
/x3
- Apply to requests mathing:
^(.+)\.(?:html|json|xml|atom|rss)$
- Condition:
REQUEST_FILENAME is not a file
- Redirect to:
Internal redirect:
index.php?$1/
- Next action:
Stop matching
Rule 2: ---------------
Redirect calls targeting the /render directory to the X3 image resizer script.
This happens if the file does not exist or if the query string contains the word 'debug'.
Without the 'debug' word, if the file exists the 'render/' requests are not redirected.
-----------------------
- Relative to base:
/x3
- Apply to requests mathing:
^render/(.+)$
- Conditions (if any of them matches):
REQUEST_FILENAME is not a file
QUERY_STRING matches with:
^(?:.*?&|)debug(?:\=.*|&.*|$)$
- Redirect to:
Internal redirect:
app/parsers/slir/index.php?$1
- Next action:
Stop matching
Rule 3: ---------------
If a request points to a file or to a directory that doesn't exist, redirect it to the X3 gallery script's index.php file.
The second parenthesis group accounts for folders with the trailing slash '/'.
-----------------------
- Relative to base:
/x3
- Apply to requests mathing:
^(.*?)(/|)$
- Conditions (all of them must match):
REQUEST_FILENAME is not a file
REQUEST_FILENAME is not a directory
- Redirect to:
Internal redirect:
index.php?/$1$2
Options:
- Append query string
- Next action:
Stop matching
---------------
Note that in all these rewrite rules, none of them have the 'Apply to subrequests' option enabled.
Subrequests is for when URLRewrite does a redirect and its further internal requests should also go through itself again.
For the redirect to www
.aurorawings
.me you can also modify it to be this way:
---------------
Relative to base:
/
Apply to requests matching:
.*
Condition (all must match):
1.
SCRIPT_URI matches with:
^http(s|)\://[^/]+?(/|$)(.+|$)$
2.
HTTP_HOST matches with:
^(?!^\.)(?!.+?\.[^\.]+?\.(?<!\.$))(.+?)(?:\.+?$|)$
Action:
External redirect to:
http$1://www.$4$2$3
* Explanations:
* $1: 's' or empty for https,
* $2: '/' or empty if not found,
* $3: the rest of the URL after a '/' if found, or empty if not,
* $4: the hostname captured in HTTP_HOST.
Next action:
Stop matching
Options:
- Append query string
Of course, all this RegEx recursion of 'must be something that must not be X thing and must be Y' surely looks like hazardeous wizardry.
The only unsure detail is whether SCRIPT_URI 100% really contains the full URL with the http(s) part.
The Abyss Web Server manual says that it does.
I didn't have any time to verify it myself.
However, considering that your photo gallery script probably needs to handle edge cases for the hostname redirect to www versions, I took the time to come up with the monstrous RegEx above.
A RegEx monstrosity, not because of actual complexity, but rather monstrous for our brains since it's basically some 'it must not be something that must not be... that must not end with...':
^(?!^\.)(?!.+?\.[^\.]+?\.(?<!\.$))(.+?)(?:\.+?$|)$
If the hostname that ultimately follows correctly matches the below requirements :
- MUST NOT begin with a dot,
- and MUST NOT begin with one or more characters followed by a dot (that if found will stop searching it further at the first occurence of it),
- followed by one or more non-dot characters followed by a dot, (that if found will stop searching it further at the first occurence of it),
- and if we found a valid 'sub.domain.' beginning, then it MUST NOT actually END with a dot.
- if the domain IS like 'domain.com.' then we DO make the RegEx valid and we will capture the hostname - but you will see later - we will NOT capture the end dots, no matter the number of dots there could be at the end.
* because, we want to capture hostnames we deem invalid (without subdomain), not the correct ones with a subdomain.
* good domain formats like 'sub.domain.com' will not match the RegEx at all and the rule will not activate.
- once we confirmed that we DO NOT have a valid subdomain there, therefore we have only a 'domain.com' hostname, then we will capture all the text of the hostname and put it in a RegEx variable.
- HOWEVER, since some people sometimes write like 'domain.com.' (which is actually also valid...), then any number of trailing dots at the very END of that hostname will NOT be captured in the RegEx variable.
For a start, I think that you should try running a separate hostname as you did, but with only the X3 gallery script - and only the x3 gallery URL rewrites with perhaps if you wish the www-redirect rewrite (for the tests you could temporarily directly connect to the www version).
If you keep the www-rewrite during the tests, then put it at the top of the urlrewrite rules list.
I think that the rewrite rules tweaks, which aren't exact conversions of the htaccess ones (I tried some RegEx bugfixes for some that perhaps were causing problems), should work atleast when using only the x3 gallery on your test server.
I hope that it will work, and I do think it should actually work.