htaccess 到 Nginx 重寫規則

htaccess 到 Nginx 重寫規則

我已將 apache htaccess 規則轉換為 nginx 重寫規則,但它們對我不起作用。

Apache .htaccess 規則

RewriteEngine On
RewriteBase /public/layout/themes/

RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

#RewriteCond %{REQUEST_URI} !^/bootstrap/
RewriteCond %{REQUEST_FILENAME} !-f [OR] 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) bootstrap/$1 [L]

Nginx 規則:

location /public/layout/themes/ {
  if (!-e $request_filename){
    rewrite ^/public/layout/themes/(.*)$ /public/layout/themes/bootstrap/$1 break;
  }
}

誰能檢查一下我在這裡做錯了什麼嗎?

答案1

我猜,你使用線上工具將你的apache規則轉換為nginx。這可能不是正確的方法。我認為,參考對你有用。

相關內容