尝试在本地服务器上添加重写,但我被卡住了。
这就是我所拥有的。
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ $uri.html $uri.php?$query_string;
}
location /news/post/ {
rewrite ^/news/post/([a-zA-Z0-9-])?$ /news/post.php?id=$1 break;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
#extra
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#--extra
}
当进入/ news / post /它说"你选择打开这个文件"并询问我是否要下载BIN文件。
如果我去/ news / post / this-is-a-news-title我得到404 Not Found。
我做错了什么?
答案 0 :(得分:0)
作品。改变了一点,需要完整的路径。
location /news/post/ {
rewrite ^/news/post/(.*)$ http://www.myserver.com/news/post.php?id=$1 break;
}