Running a Flynax website often comes with unique challenges—especially when migrating from a cPanel-based Apache server to a more modern stack like Ubuntu 22.04 with CloudPanel. One of the most common issues users face is related to URL rewrites, since Apache uses .htaccess
while CloudPanel runs on Nginx, which handles rewrites differently.
In this article, I’ll walk you through my own migration experience and show you how to fix the rewrite rules for Flynax when running on CloudPanel.
Why I Chose CloudPanel Instead of cPanel
Most Flynax installations are hosted on Apache web servers, making use of .htaccess
for URL rewriting. However, things got complicated when I had to migrate a Flynax website that requires PHP 7.4.
Here’s the problem:
-
PHP 7.4 is End-of-Life (EOL), meaning it no longer receives official security updates.
-
Latest cPanel releases have dropped support for older PHP versions like 7.4, forcing users to upgrade.
-
But Flynax doesn’t work smoothly with newer PHP versions, leaving me with limited options.
That’s when I decided to switch to CloudPanel on Ubuntu 22.04. Unlike cPanel, CloudPanel gives you the flexibility to run multiple PHP versions—from 7.1 all the way up to 8.4—without compromising on the stability of your operating system.
The Rewrite Rule Challenge with Nginx
After installing CloudPanel and setting up Flynax, I immediately noticed a major issue:
-
Only the homepage was loading.
-
All other pages returned errors.
This happened because CloudPanel uses Nginx instead of Apache, and .htaccess
rules are not compatible with Nginx. To make Flynax work, I had to manually translate the Apache rewrite rules into Nginx rewrite rules inside the vhost configuration file.
Working Nginx Configuration for Flynax
Here’s the vhost configuration that solved my problem. You can adapt it to your own domain and server setup:
server {
# ... other configuration ...
server_name
your-domain.com
www.your-domain.com
~^(?<subdomain>.*)\.your-domain\.com$;
# Homepage
location = / {
try_files $uri /index.php?$args;
}
# Admin panel
location = /admin/ {
try_files $uri /admin/index.php?$args;
}
# General rewrites
location / {
try_files $uri $uri/ @flynax-rewrite;
}
# Static files caching
location ~* \.(jpg|jpeg|gif|png|svg|woff|pdf|swf)$ {
expires 365d;
}
location ~* \.(css|js)$ {
expires 93d;
}
# Flynax rewrite rules
location @flynax-rewrite {
rewrite "^/([^//]+)/?(.*)?/index([0-9]*).html$" /index.php?page=$1&rlVareables=$2&pg=$3 last;
rewrite "^/([^/]+)(/?(.{2,}))?-l?([0-9]+).html$" /index.php?page=$1&rlVareables=$3&listing_id=$4 last;
rewrite "^/((\w{2})/)?([\w\-_]{3,})$" /index.php?page=$3&lang=$2&account_request last;
rewrite "^/([^//]+)/?(^/*)?.html$" /index.php?page=$1 last;
rewrite "^/([^//]+)/?(.*)?/?(.*)?(.html|/+)$" /index.php?page=$1&rlVareables=$2 last;
rewrite "^/^api/v[0-9]+/?.*$" /plugins/api/request.php last;
rewrite "^/sitemap.xml$" /plugins/sitemap/sitemap.php last;
rewrite "^/plugins/iFlynaxConnect/api.json$" /plugins/iFlynaxConnect/request.php last;
rewrite "^/plugins/hybridAuthLogin/(.*)$" /plugins/hybridAuthLogin/requests.php?provider=$1 last;
return 404;
}
# ... other configuration ...
}
Why This Setup Works
-
Homepage & Admin URLs: Handled by direct rules with
try_files
. -
Flynax Dynamic Pages: Rewritten to
index.php
with correct parameters. -
Static Assets: Cached for better performance.
-
Plugins & API: Custom rewrite rules ensure sitemap, API, and login features keep working.
With these rules in place, the website started functioning exactly as it did on the old Apache server.
Final Thoughts
While it’s not ideal to use PHP 7.4 since it’s already EOL, sometimes real-world constraints force us to make compromises. By using CloudPanel with Ubuntu 22.04, I was able to:
-
Run Flynax smoothly with the required PHP version.
-
Translate Apache
.htaccess
rules into Nginx vhost rules. -
Restore full functionality of the website without being locked into outdated hosting environments.
If you’re planning to migrate Flynax from cPanel to CloudPanel, this Nginx configuration should save you hours of trial and error.