2013-10-05 42 views
0

我想添加Apache .htaccess規則。這是從舊服務器的nginx:Smarty .htaccess重寫(來自nginx)

location ~ \.php$ { 
    fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
    fastcgi_index index.php; 
    include fastcgi_params; 
} 

    location/{ 
    if (-f $request_filename) { 
     break; 
    } 
    if (-d $request_filename) { 
     break; 
    } 
    rewrite ^/(.*) /index.php?demand=$1; 
} 

如何重寫這個?我現在所得到的只是索引頁,其餘的文件都沒有找到。我真的希望在這裏得到一些幫助,謝謝。

回答

1

重寫部分應該簡單地:

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

要強制使用HTTPS,添加此之前上面的規則:

RewriteCond %{HTTPS} off 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
+0

我怎麼能包括強制使用https? – mortusdetus

+0

您是否看到過這個問題? http://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite – Yaroslav

+0

@mortusdetus查看編輯 –