Php 将.htaccess mod_rewrite转换为nginx指令时出现问题
我很难将此apache重写规则转换为nginx:Php 将.htaccess mod_rewrite转换为nginx指令时出现问题,php,.htaccess,nginx,Php,.htaccess,Nginx,我很难将此apache重写规则转换为nginx: <IfModule mod_rewrite.c> RewriteEngine On Options +FollowSymLinks Options -Indexes RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule . index.php [L,QSA] </IfMo
<IfModule mod_rewrite.c>
RewriteEngine On
Options +FollowSymLinks
Options -Indexes
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule . index.php [L,QSA]
</IfModule>
B:
location / {
try_files $uri $uri/ index.php$is_args$args;
}
location / {
try_files $uri $uri/ index.phps$args;
}
但是,对于任何/path
,A都会给出404错误,而B则适用于/path/to/where
,但会下载/path
以下是我的完整vhost:
server {
listen 8000;
root /var/www/myphpapp;
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
#autoindex off;
location / {
try_files $uri $uri/ index.php$is_args$args; #A
#try_files $uri $uri/ /index.php?$args; #B
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
所以我想知道什么是正确的nginx指令?我认为是输入错误。你错过了一个斜杠:
try_files $uri $uri/ /index.php$is_args$args;
当我使用
/index.php$is_args$args
时,当我访问/signup
页面时,它只下载index.php
,这意味着nginx将请求转发到index.php,但它不知道如何执行该文件。所以现在的问题是在php设置中。你能分享更多关于你的设置的信息吗?