This article mainly introduces the PHP symfony and codeigniter framework nginx rewrite rule configuration, the text in the configuration of the key to some of the rewrite writing to explain, the need for friends can refer to the next
Symfony
Symfony foreign very popular PHP framework, the current domestic use of relatively few, but will certainly in the domestic fire up. Nginx rewrite rules are as follows
server {server_name php.cn www.php.cn; root/data/site/www.php.cn;location/{# Try to serve file directly, fallback to Rewrite try_files $uri @rewriteapp; }location @rewriteapp {# rewrite all to app.php rewrite ^ (. *) $/app.php/$1 last;} Location ~ ^/(app|app_dev|config). PHP (/|$) {fastcgi_pass unix:/var/run/php5-fpm.sock; # change to your corresponding fastcgi fastcgi_split_ Path_info ^ (. +.php) (/.*) $; Include Fastcgi_params; Fastcgi_param script_filename $document _root$fastcgi_script_name; Fastcgi_param HTTPS off; }error_log/data/logs/nginx/www.php.cn_error.log; }
Restart Nginx
CodeIgniter
CodeIgniter, that is a lot of people referred to as CI high-popularity PHP framework, in which the text community is also more active, to look at the CI rewrite wording:
server {listen; server_name php.cn www.php.cn;root/data/site/www.php.cn; index index.php; Error_log log/error.log;# S Et expiration of assets to MAX for caching location ~*. (ico|css|js|gif|jpe?g|png) (? [0-9]+)? $ {expires max; log_not_found off;} # main codeigniter Rewrite rule location/{Try_files $uri $uri//index.php;} # PHP parsing location ~. php$ {root/data/site/php.cn/; try_files $uri =404; fastcgi_pass unix:/tmp/php5-fpm.sock; # change to the right FastCGI Fastcgi_index index.php; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params; Fastcgi_buffer_size 128k; Fastcgi_buffers 4k; Fastcgi_busy_buffers_size 256k; Fastcgi_temp_file_write_size 256k; }}
Modify the CI (codeigniter) configuration file config.php
$config [' base_url '] = "//www.php.cn/"; $config [' index_page '] = ""; $config [' uri_protocol '] = "Request_uri";
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!