新版Notadd 配置

前后端同一台服务器配置:

  1. 所有搜索引擎的请求,交由后端处理。
  2. 所有404 (文件不存在)路由 交由index.html 前端处理。
  3. 所有API 相关交由 后端处理

nginx



location ^(?api|admin) {
    if ($http_user_agent ~* "bot|spider|Bot|Spider"){
        try_files $uri $uri/ /boot.php?$query_string;
    }
    try_files $uri $uri/ /index.html =404;
}

location ^(api|admin) {
    try_files $uri $uri/ /boot.php?$query_string;
}

caddy

0.0.0.0:80 {
    root ./demo
    fastcgi / 127.0.0.1:9000 php
    rewrite {
        if {>Header} has bot
        if {>Header} has spider
        if_op or
        to  /boot.php

    }
    rewrite {
	if {path} not_starts_with /api
    # r ^/api
	to {path} {path}/ /index.html
    }
    rewrite {
	if {path} starts_with /api
    # r ^/api
	to  /boot.php
    }
}

Apache

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond  %{HTTP_USER_AGENT}  *(bot|spider|Bot|Spider)  boot.php [L]
RewriteRule ^(api|admin) boot.php [L]
RewriteRule ^(?api|admin) index.html [L]

转载于:https://my.oschina.net/zhdong/blog/1358550

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值