Nginx rewrite rule configuration for PHP symfony and CodeIgniter frameworks

Source: Internet
Author: User
Tags php framework codeigniter
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.