Saya perlu memigrasikan situs web berbasis Apache php ke lighttpd tetapi saya mendapatkan beberapa masalah untuk mengubahnya.
Struktur direktori saya adalah:
-rootdir
--index.php¹
--login.php²
--views²
--server
---service³
---auth³
¹ Di rootdir, aturan penulisan ulang di Apache adalah:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(js|ico|gif|jpg|png|css|html)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
² file login.php dan folder tampilan perlu dihindari dengan menulis ulang ³ Direktori server/auth dan server/layanan memiliki penulisan ulang Anda sendiri:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Mencoba membuat aturan, dan hampir semuanya baik-baik saja, tetapi /server/service tidak
url.rewrite-if-not-file = (
"^/login.php\/?([^.]+)$/" => "/login.php/$1", #ok
"^/(views|assets|css|images|application)/(.*)" => "$0", #ok
"/server/service/.*\?(.*)$" => "/server/service/index.php?$1", #return rewrite response of rootdir/index.php
"/server/auth/.*\?(.*)$" => "/server/auth/index.php?$1", #ok
"/.*\.(js|ico|gif|jpg|png|css|html)$" => "$0", #ok
"/.*\?(.*)$" => "/index.php?$1",
"" => "/index.php"
)
contoh penggunaan:
www.example.com/home/id/2 ‹-- gunakan /rootdir/index.php www.example.com/server/auth/check/sessionid2235232132 ‹-- gunakan /server/auth/index.php www.example. com/server/server/db/clients/getall ‹-- gunakan /server/service/index.php