我试图把我的网站从Apache移动到Nginx。 我的网站是这样构build的:
所有请求都使用.htaccess从www_rootredirect到公用文件夹,其中包含:
RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L]
在公共文件夹中 ,所有的请求都被redirect到单个入口点index.php .htaccess:
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1 [QSA,L]
目前我的服务器块是这样的:
server { server_name domain.com www.domain.com; root /var/www/domain.com/htdocs/public; location / { # try to serve file directly, fallback to index.php try_files $uri /index.php$is_args$args; } location ~ ^/index\.php(/|$) { fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; internal; } }
所以我只能通过添加查询string来查看所需的页面。 例如http://www.domain.com/?page=the/page/to/see
我怎样才能用Nginx做到这一点? 我尝试了很多解决scheme,但没有成功
感谢您的帮助 !