2016-05-30 3 views
0

nginxのします再作業のApacheの.htaccess私は私がやった代わりに<code>http://domain.com/?page=main</code></p> <p>を使用しての<code>http://domain.com/main</code>を使用するために私のnginxを書き換えしようとしているコンフィギュレーション

try_files $uri $uri/ /index.php?page=$uri; 

戻り値を空白のページ

rewrite ^/(\w+)$ /index.php?page=$1 break; 
rewrite ^/(\w+)+\/$ /index.php?page=$1 break; 
if ($http_host !~ "^$"){ 
    rewrite ^(.*)$ http%1://www.$http_host$request_uri redirect; 
} 

URLを生成します。http://domain.com/main/http://domain.com/main/http://domain.com/main

ここはApacです彼は.htaccessファイル:

RewriteEngine on 
RewriteRule ^(\w+)$ index.php?page=$1 [L,NC,QSA] 
RewriteRule ^(\w+)+\/$ index.php?page=$1 [L,NC,QSA] 
RewriteCond %{HTTP_HOST} !^$ 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
+0

バンプを使用できますか? – swagster

答えて

0

私は、フォームのURIの作業の構成を有していると仮定しています:それは生成されますよう期待通りtry_files $uri $uri/ /index.php?page=$uri;が動作しない場合がありhttp://domain.com/?page=main

http://domain.com/?page=/main 

余分に/に注意してください。したがって、先導/を含まないURIの一部を取り出すためにリライトを使用する必要があります。たとえば、次のターゲットURIが別の場所で処理される必要があるよう

location/{ 
    try_files $uri $uri/ @rewrite; 
} 
location @rewrite { 
    rewrite ^/(.*)$ /index.php?page=$1 last; 
} 
location \.php$ { ... } 

は、lastサフィックスなくbreakサフィックスに注意します。詳細は、this documentを参照してください。

関連する問題

 関連する問題