Redirect 301 Issues


New Member
Hello, I recently setup an OLS server (1.4.41) on Ubuntu 18.04 w/ LSPHP 7.2 running WordPress (WP) and it works great, however redirect 301's are causing me some headaches. Rewrite is enabled, and LSCache is installed on WP. It works fine and the rewrite to remove WP index,php is working. However, simple 301 redirects in my htaccess file do not work.

Basic settings in htaccess
RewriteEngine on
RewriteBase /

Example of an issue:
redirect 301 /old/file-name.php

This just produces a 404 error. Any file with a .php does not redirect.

If I try:
redirect 301 /old/file-name

If the file name and directory are close it seems to pattern match and redirect to a similar URL but not necessarily the one I want it to go to.

The directory I use for WP files is /home/aod/wp/

Error logs shows this:

[INFO] Tried to add new context: URI /2006/ location /home/aod/wp//2006/, result 0x5632e9eaffc0
[REWRITE] Source URI: '2006/06/alberta-premium-rye-whisky.php' => Result URI: '/index.php'
[INFO] Tried to add new context: URI /wp-admin/ location /home/aod/wp//wp-admin/, result 0x5632e9ec3e90

I can see the // in the uri but don't know where it is coming from.

The two example work fine in Apache 2.4. And it is important for me to maintain these redirects as this site has been around since 2005 (MoveableType days) and to maintain so of my Google rank for SEO purposes I need these links going to the right place. I'm hoping to move to OLS but this would be a deal breaker.

Thanks for any help. Cheers

Other Details:
Using the following for index.php removal in WP:
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


New Member
Ok. In the meantime I've found another solution. Using Rewrite ^/ in the vitrualhost rules section works, but it has to be above the rules that remove index.php from WordPress url's.

RewriteRule ^/?index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


There are a few things:
1. rewrite rules in .htaccess and rewrite rules in the virtual host rewrite section are different.
You can simply use apache .htaccess rewrite rule, just need to create a "/" context and write rewrite rule there, or simply specify the rewrite file path as: "rewriteFile /file/path/to/.htaccess" at the "/" context "Rewrite Rules" area.

2. Only rewrite rules work in .htaccess with OpenLiteSpeed. "redirect 301" may not work with OpenLiteSpeed in .htaccess(it works with LiteSpeed EnterPrise). hence, you may use rewrite rules instead. For example:

RewriteEngine on
RewriteRule ^old/file-name.php [L,R=301]

3. Every time you make changes to .htaccess, you will need to restart OpenLiteSpeed to apply the changes. This is different to LiteSpeed Enterprise, and there is no restart required for LSWS when there is any changes in .htaccess.
Last edited:


New Member
Thanks, very useful information and using RewriteRule will work for my purposes. The more I use OLS the more I like it. Cheers