ฉันต้องย้ายเว็บไซต์ที่ใช้ Apache php ไปยัง lighttpd แต่ฉันประสบปัญหาในการเปลี่ยนแปลง
โครงสร้าง dir ของฉันคือ:
-rootdir
--index.php¹
--login.php²
--views²
--server
---service³
---auth³
¹ ใน rootdir กฎการเขียนซ้ำใน Apache คือ:
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]
² จำเป็นต้องหลีกเลี่ยงไฟล์ login.php และโฟลเดอร์มุมมองโดยการเขียนใหม่ ³ เซิร์ฟเวอร์/การรับรองความถูกต้อง และไดเรกทอรีเซิร์ฟเวอร์/บริการมีการเขียนใหม่ของคุณเอง:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
กำลังพยายามสร้างกฎและเกือบทั้งหมดก็ถูกต้อง แต่ /server/service ไม่ใช่
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"
)
ตัวอย่างการใช้งาน:
www.example.com/home/id/2 ‹-- ใช้ /rootdir/index.php www.example.com/server/auth/check/sessionid2235232132 ‹-- ใช้ /server/auth/index.php www.example com/server/server/db/clients/getall ‹-- ใช้ /server/service/index.php