0
我有一個htaccess文件我想轉換成nignx配置文件。在Nginx的htaccess重寫規則:設置重寫路徑
這是我的htaccess文件。
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule !\.(jpg|css|js|gif|png)$ public/ [L]
RewriteRule !\.(jpg|css|js|gif|png)$ public/index.php?url=$1
和我有規則,我的nginx的配置文件:
location/{
if ($request_uri !~ "-f"){
rewrite !\.(jpg|css|js|gif|png)$ public/ break;
}
rewrite !\.(jpg|css|js|gif|png)$ public/index.php?url=$1;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
# Move to the @missing part when the file doesn't exist
try_files $uri @missing;
# Fix for server variables that behave differently under nginx/$
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Include the standard fastcgi_params file included with ngingx
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
# Pass to upstream PHP-FPM; This must match whater you name you$
#fastcgi_pass phpfpm;
fastcgi_pass 127.0.0.1:9000;
}
location @missing {
rewrite ^(.*)$ public/index.php?url=$1 break;
}
然而,當我打/,我得到一個禁止的403,但是我能到/public/index.php,因此重寫不起作用。
關於我在做什麼錯的任何想法?