1

Here are the htaccess codes that CakePHP uses:-

I want to rewrite them/ convert them so that they run on my openlitespeed server. They work perfectly fine on a standard apache server.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>    


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
</IfModule>


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
  • Here is another one which I am personally using with the code.. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] – Harsh Kumar Feb 09 '18 at 08:22

1 Answers1

1

Simply add rewrite rules in Context of the virtual host you want.

Add static context of the virtual host
Parameters of context:
- URl = /
- Location = default path e.g. /usr/local/lsws/Example/html/
- Accessible =Yes
- Enable Rewrite = Yes
- Rewrite Rules=

RewriteRule    ^(.*)$ app/webroot/    [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]

You can still put all your original rules to rewrite.
I just put one rule RewriteRule ^(.*)$ app/webroot/ [L] because I don't understand why need other rules. webroot/ and webroot/$1 seem never be matched.

RewriteRule    ^$ app/webroot/    [L]
RewriteRule    (.*) app/webroot/$1 [L]
RewriteRule    ^$    webroot/    [L]
RewriteRule    (.*) webroot/$1    [L]
Eric
  • 732
  • 4
  • 13