將 RewriteRule 從 nginx 轉換為 apache

將 RewriteRule 從 nginx 轉換為 apache

我想將 nginx 重寫規則轉換為 htaccess 重寫規則。

nginx 如下:

rewrite ^/(.*)$ /index.php?$1 last;

我嘗試過:

RewriteEngine On
RewriteRule ^/(.*)$ /index.php?$1

……但我工作不正常。 (未找到頁面)

如果有人能幫助我,那就太好了。

編輯:

我稍微改變了“Logic Wreck”的建議(因為不可能將index.php改為另一個):

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L]

而且效果很好:)。

答案1

試試這些:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

相關內容