PHP的Symfony和CodeIgniter框架的Nginx重写规则配置
程序员文章站
2022-05-24 14:54:02
symfony
symfony国外很流行的php框架,目前国内用的相对较少,但是一定会在国内火起来. nginx重写规则如下
server {
server...
symfony
symfony国外很流行的php框架,目前国内用的相对较少,但是一定会在国内火起来. nginx重写规则如下
server { server_name jb51.net www.jb51.net; root /data/site/www.jb51.net; 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; # 改成你对应的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.jb51.net_error.log; }
重启nginx即可
codeigniter
codeigniter,即被很多人简称为ci的高人气php框架,其中文社区也比较活跃,来看一下ci的rewrite写法:
server { listen 80; server_name jb51.net www.jb51.net; root /data/site/www.jb51.net; index index.php; error_log log/error.log; # set 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/jb51.net/; try_files $uri =404; fastcgi_pass unix:/tmp/php5-fpm.sock; # 改成对应的fastcgi fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; } }
修改ci(codeigniter )配置文件config.php
$config['base_url'] = "//www.jb51.net/"; $config['index_page'] = ""; $config['uri_protocol'] = "request_uri";
推荐阅读
-
解析CI即CodeIgniter框架在Nginx下的重写规则
-
解析CI即CodeIgniter框架在Nginx下的重写规则
-
解析CI即CodeIgniter框架在Nginx下的重写规则_PHP教程
-
PHP的Symfony和CodeIgniter框架的Nginx重写规则配置
-
Nginx配置PHP的Yii与CakePHP框架的rewrite规则示例
-
解析CI即CodeIgniter框架在Nginx下的重写规则
-
解析CI即CodeIgniter框架在Nginx下的重写规则_PHP
-
解析CI即CodeIgniter框架在Nginx下的重写规则
-
解析CI即CodeIgniter框架在Nginx下的重写规则_PHP
-
解析CI即CodeIgniter框架在Nginx下的重写规则_php实例