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>
1
  • Here is another one which I am personally using with the code..<IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> Feb 9, 2018 at 8:22

1 Answer 1

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]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.