2012-05-07 43 views
1

我有以下重寫規則。需要他們來獲取CoolURI,以便在apache服務器上運行typo3。現在我想爲nginx服務器做同樣的事情。將重寫規則轉換爲針對typo3的nginx conf

RewriteEngine On 

RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)$ - [L] 
RewriteRule ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/.*$ - [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule .* index.php 

任何人都可以幫助我將這些轉換爲Nginx conf?我發現這http://nginx.org/en/docs/http/converting_rewrite_rules.html,但我真的是新的nginx,並不知道如何轉換此...

任何想法?

回答

4

這應該工作:

location/{ 
    index index.php index.html index.htm; 
    try_files $uri @rewrite; 
} 

location @rewrite { 
    rewrite ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)$ - last; 
    rewrite ^/(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/.*$ - last; 
} 

你會把這個server { ... }聲明中。

我不使用Typo3,所以我不能確定它是否可以工作,但它可能只是需要一些基本的調整。

+0

這裏不是最後一個'RewriteRule。* index.php'丟失嗎? –

+0

@MichaelHärtl你不需要用'location/{...}'塊的寫法來重寫index.php。 – Brendan

+1

對不起,但我認爲你錯了。我試過了,但它對我沒有用。在'location @ rewrite'裏面最後一個'rewrite'下面,我必須添加'try_files $ uri /index.php;'來使它工作。 –