안녕하세요 mod_rewrite를 올바르게 설정하려고하는데 Lighttpd에 아무 문제가 없었지만 스왑도 nginx로 바꾸고 싶었습니다.Nginx Mod_Rewrite
location /highscores {
rewrite ^/highscores /?page=highscores last;
}
location /highscores/ {
rewrite ^/highscores/(.*)/(.*)$ /?page=highscores&list=$1&page=$2 last;
}
문제는 당신과 같은 방향을 세우면/최고 기록/끝 /와 오류 404가, 당신은/최고 기록을하려고하면/예를 들어이뿐만 아니라 404이지만,/최고 기록/예/아무도이 문제를 해결할 수 있습니까?
Google에서 해결책을 찾을 수 있습니다.
구성
server {
listen 80;
server_name example.com;
root /usr/share/nginx/www/example.com;
include /etc/nginx/include.d/all-common;
include /etc/nginx/include.d/example.com;
}
모든 일반적인
index index.php index.html index.htm;
try_files $uri $uri/ /index.html;
location/{
try_files $uri $uri/ = /;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
example.com include.d에서 내가 최고
Regexp'^/highscores /(.*)$'는'/ highscores /'나'/ highscores/example'과 일치하지 않으므로이 다시 쓰기가 적용되지 않습니다. 다시 쓰는 것은 무엇을 기대합니까? –
또한 궁금합니다. 왜 두 페이지의 인수가 필요합니까? –
하나만 있으면되지만 전혀 작동하지 않습니다. example.com/highscores 404 example.com/highscores/ 404 example.com/highscores/example가 아니라 그것을해야에서 작동하고 보여줍니다, 잘못 PARM의 목록을 보여줍니다 = $ (1) – WinterTime