2016-05-26 6 views
1

URLの書き換え時にnginxの設定が正常に行えません。NginxのURLの設定

私が持っている:

example.com/post.php?slug=example 

私はそれになりたい:htaccessファイルについては

example.com/nyheder/slug 

私はそれが仕事を得るためにのために、それは簡単です。 nginxので

RewriteRule ^/?nyheder/(.*?)/?$ /post.php?slug=$1 [L] 

私はいくつかの方法を試してみました:助けることができる

location/{ 
     try_files $uri $uri/ $uri.html $uri.php?$query_string; 
    } 

    location /post.php { 
     rewrite ^/?nyheder/(.*?)/?$ /post.php?slug=$1 last; 
    } 

誰を?

答えて

0

ルールをlocation /または親のserverディレクティブに移動する必要があります。このいずれかで

location/{ 
    rewrite ^/nyheder/(.*)$ /post.php?slug=$1 break; 

    try_files $uri $uri/ $uri.html $uri.php?$query_string; 
} 
+0

、それは代わりに、ファイルをダウンロードします。

のような場所ディレクティブをお試しください。 http://139.162.165.252/nyheder/the-cyber-house-rules –