新版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]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章