I’ve installed a CodeIgniter app on an OpenLiteSpeed server, and although the script installation went smoothly, there appears to be a problem with the .htaccess
redirects.
Pages only seem to work when adding “index.php” at the beginning of the URL, such as https://app.example.com/index.php/admin
. If I visit https://app.example.com/admin
, the site breaks.
The contents of my .htaccess
file is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
# RewriteBase could be necessary depending on your server setup
# RewriteBase /
# Add this to handle requests to your CodeIgniter front controller
RewriteCond %{REQUEST_URI} !^/(index\.php|assets|robots\.txt|favicon.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
# Existing rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !.(js|css|eot|svg|ttf|woff|woff2|map)$ index.php [L]
RewriteCond $1 !^(index\.php|assets)
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
# Redirect requests for favicon.ico to the actual file
Redirect 301 /favicon.ico /assets/images/favicon.ico
# Deny access to .env file
<Files .env>
Order allow,deny
Deny from all
</Files>
</IfModule>
Any help would be appreciated.
I tried editing the .htaccess
file inline with any documentation I could find online pertaining to OpenLiteSpeed and redirects, but have had no joy so far.
The issue is not with your .htaccess
file — it’s that OpenLiteSpeed does not support .htaccess
files the same way Apache does.
Straight answer:
OpenLiteSpeed ignores most Apache-style .htaccess
rules unless they are explicitly converted into the server’s admin configuration. That’s why index.php
is required — your rewrites aren’t being applied.
How to fix it:
Step 1: Login to OpenLiteSpeed Admin Panel
- Usually available at:
http://your-server-ip:7080
- Login with your admin credentials
Step 2: Go to Virtual Hosts > [Your Virtual Host] > Rewrite
- Click on your virtual host name (e.g.
Example
)
- Go to the “Rewrite” tab
Step 3: Enable Rewrite Rules
Set the following:
- Enable Rewrite:
Yes
- Auto Load from .htaccess:
Yes
If it’s already set, the next step is critical.
Step 4: Add your rewrite rules to “Rewrite Rules” section
Copy this into the Rewrite Rules text box:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(index\.php|assets|robots\.txt|favicon.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
This is the minimal and correct rule for CodeIgniter 4 front-controller routing.
Step 5: Restart OpenLiteSpeed
After saving, restart OpenLiteSpeed:
- Go to Actions > Graceful Restart or restart from CLI:
sudo systemctl restart lsws
Optional: Update app.baseURL
Make sure your app/Config/App.php
or .env
file has:
app.baseURL = 'https://app.example.com/'
Summary:
- OpenLiteSpeed does not fully honor
.htaccess
— you must configure rewrite rules in its admin panel
- Add your CodeIgniter rewrite rules under Virtual Hosts > Rewrite Rules
- Restart server after changes
Let me know if you need exact UI navigation for your hosting control panel or if you’re using CyberPanel (which runs on OpenLiteSpeed).