web服务器url重写

nginx

判断是否能找到该文件,如果找不到,则进行url重写
if (!-f $request_filename){
        rewrite (.*) /index.php;
 }

location /jitamin/public/{

	if (!-f $request_filename){
            rewrite ^/jitamin/public/(.*)$ /jitamin/public/index.php;
     }
    if (!-e $request_filename){
            rewrite ^/jitamin/public/(.*)$ /jitamin/public/index.php;
          
     }
}

nginx作用
前端服务器:负责http请求解析转发,或者处理静态请求。轻量级,并发量高,可以作为反向代理,负载均衡。
应用服务器:负责调用某种语言的解释器,或则某某种语言写的程序,接受http请求,按照开发者意图做出动作,把结果返回给请求。

Nginx不只有处理http请求的功能,还能做反向代理。Nginx通过反向代理功能将动态请求转向后端Php-fpm。

location ~ .php${
include  ...../nginx/fastcgi.conf; #加载nginx的fastcgi模块
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000; #nginx fastcgi进程监听的IP地址和端口
}

php-fpm是fastcgi的实现,并提供了进程管理功能。进程包含了master和worker两种进程。
master进程只有一个,负责监听端口,接收webserver请求;然而worker进程有多个,每个进程都嵌入了php解释器,是php代码真正执行的地方。

apache

  1. httpd.conf配置文件中加载了mod_rewrite.so模块
  2. AllowOverride None 将None改为 All
  3. 在应用入口文件同级目录添加.htaccess文件,内容如下:
 <IfModule mod_rewrite.c>
    Options +FollowSymlinks -Multiviews
    RewriteEngine on
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值