나는 라스베리 파이에 nginx를 가지고 있습니다. /etc/nginx/sites-available/default
에서 server{}
을 다음으로 대체했으며 http://192.168.1.210/을 사용하여 /var/www/html/index.php
에 액세스 할 수 있습니다.nginx를 index.php로 리디렉션
server {
listen 80;
server_name $domain_name;
root /var/www/html/;
index index.html index.htm;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location ~\.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
try_files $uri =404;
include fastcgi_params;
# if (!-e $request_filename){ rewrite ^(.*)$ /index.php break; }
}
}
는 지금은 아파치의
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
내가 (위의 주석 라인을 참조) 끝에 if (!-e $request_filename){ rewrite ^(.*)$ /index.php break;
을 추가하고 브라우저에 http://192.168.1.210/page2을 배치하지만, 스크립트와 유사한 몇 가지 간단한 리디렉션을 추가 할 여전히 리디렉션되지 않음 /var/www/html/index.php
어떻게 존재하지 않는 요청을 index.php로 리디렉션 할 수 있습니까?
내가 이전에 시도했다가 그러나 첫 번째 해결책은 다음과 같은 오류가 발생합니다 :'michael @ raspberrypi : ~ $ sudo /etc/init.d/nginx restart [....] nginx를 재시작 (systemctl을 통해) : nginx.service의 nginx.serviceJob 실패 에드. 자세한 내용은 'systemctl status nginx.service'및 'journalctl -xn'을 참조하십시오. 'systemctl status nginx.service'는 에러를 보여 주지만,'journalctl -xn'은 아무것도 표시하지 않습니다. 실패! '. 두 번째 솔루션은 오류를 발생시키지 않지만 여전히 리디렉션하지 않습니다. 감사합니다 – user1032531
당신은 장소 바로 밖에서 그 try_files 장소 않았다? – spa900
아니요,하지만 그 이후로. 완전한! – user1032531