2013-10-05 48 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查看编辑 –