Skip to content

Instantly share code, notes, and snippets.

@coolicer
Last active January 1, 2016 14:19
Show Gist options
  • Save coolicer/8157121 to your computer and use it in GitHub Desktop.
Save coolicer/8157121 to your computer and use it in GitHub Desktop.
Thinkphp3.2 URL Rewrite
server {
listen 8080;
root /home/www/;
index index.html index.htm index.php;
server_name localhost;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
server {
listen 8080;
server_name demo.com www.demo.com;
root /home/www/php/tp/;
index index.html index.htm index.php;
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
set $script $uri;
set $path_info "/";
if ($uri ~ "^(.+\.php)(/.+)") {
set $script $1;
set $path_info $2;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php?IF_REWRITE=1;
include fastcgi_params;
fastcgi_param PATH_INFO $path_info;
fastcgi_param SCRIPT_FILENAME $document_root/$script;
fastcgi_param SCRIPT_NAME $script;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment