mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-13 17:24:44 +08:00
feat: 增加伪静态设置 (#640)
This commit is contained in:
parent
e7608673d7
commit
6595ad6228
@ -560,3 +560,47 @@ func (b *BaseApi) UpdatePHPFile(c *gin.Context) {
|
||||
}
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags Website
|
||||
// @Summary Get rewrite conf
|
||||
// @Description 获取伪静态配置
|
||||
// @Accept json
|
||||
// @Param request body request.NginxRewriteReq true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /websites/rewrite [post]
|
||||
func (b *BaseApi) GetRewriteConfig(c *gin.Context) {
|
||||
var req request.NginxRewriteReq
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
res, err := websiteService.GetRewriteConfig(req)
|
||||
if err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithData(c, res)
|
||||
}
|
||||
|
||||
// @Tags Website
|
||||
// @Summary Update rewrite conf
|
||||
// @Description 更新伪静态配置
|
||||
// @Accept json
|
||||
// @Param request body request.NginxRewriteUpdate true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /websites/rewrite/update [post]
|
||||
// @x-panel-log {"bodyKeys":["websiteID"],"paramKeys":[],"BeforeFuntions":[{"input_colume":"id","input_value":"websiteID","isList":false,"db":"websites","output_colume":"primary_domain","output_value":"domain"}],"formatZH":"伪静态配置修改 [domain]","formatEN":"Nginx conf rewrite update [domain]"}
|
||||
func (b *BaseApi) UpdateRewriteConfig(c *gin.Context) {
|
||||
var req request.NginxRewriteUpdate
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := websiteService.UpdateRewriteConfig(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
@ -19,3 +19,14 @@ type NginxConfigUpdate struct {
|
||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||
Params interface{} `json:"params"`
|
||||
}
|
||||
|
||||
type NginxRewriteReq struct {
|
||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
type NginxRewriteUpdate struct {
|
||||
WebsiteID uint `json:"websiteId" validate:"required"`
|
||||
Name string `json:"name" validate:"required"`
|
||||
Content string `json:"content" validate:"required"`
|
||||
}
|
||||
|
@ -47,3 +47,7 @@ type WebsiteLog struct {
|
||||
type PHPConfig struct {
|
||||
Params map[string]string `json:"params"`
|
||||
}
|
||||
|
||||
type NginxRewriteRes struct {
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ type Website struct {
|
||||
ErrorLog bool `json:"errorLog"`
|
||||
AccessLog bool `json:"accessLog"`
|
||||
DefaultServer bool `json:"defaultServer"`
|
||||
Rewrite string `gorm:"type:varchar" json:"rewrite"`
|
||||
RuntimeID uint `gorm:"type:integer" json:"runtimeID"`
|
||||
Domains []WebsiteDomain `json:"domains" gorm:"-:migration"`
|
||||
WebsiteSSL WebsiteSSL `json:"webSiteSSL" gorm:"-:migration"`
|
||||
|
@ -2,12 +2,14 @@ package service
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/app/api/v1/helper"
|
||||
"github.com/1Panel-dev/1Panel/cmd/server/nginx_conf"
|
||||
"gorm.io/gorm"
|
||||
"os"
|
||||
"path"
|
||||
@ -57,6 +59,8 @@ type IWebsiteService interface {
|
||||
GetPHPConfig(id uint) (*response.PHPConfig, error)
|
||||
UpdatePHPConfig(req request.WebsitePHPConfigUpdate) error
|
||||
UpdatePHPConfigFile(req request.WebsitePHPFileUpdate) error
|
||||
GetRewriteConfig(req request.NginxRewriteReq) (*response.NginxRewriteRes, error)
|
||||
UpdateRewriteConfig(req request.NginxRewriteUpdate) error
|
||||
}
|
||||
|
||||
func NewIWebsiteService() IWebsiteService {
|
||||
@ -981,3 +985,74 @@ func (w WebsiteService) UpdatePHPConfigFile(req request.WebsitePHPFileUpdate) er
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w WebsiteService) UpdateRewriteConfig(req request.NginxRewriteUpdate) error {
|
||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
nginxFull, err := getNginxFull(&website)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
includePath := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.PrimaryDomain, website.PrimaryDomain)
|
||||
absolutePath := path.Join(nginxFull.Install.GetPath(), includePath)
|
||||
fileOp := files.NewFileOp()
|
||||
var oldRewriteContent []byte
|
||||
if !fileOp.Stat(path.Dir(absolutePath)) {
|
||||
if err := fileOp.CreateDir(path.Dir(absolutePath), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if !fileOp.Stat(absolutePath) {
|
||||
if err := fileOp.CreateFile(absolutePath); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
oldRewriteContent, err = fileOp.GetContent(absolutePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := fileOp.WriteFile(absolutePath, strings.NewReader(req.Content), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := updateNginxConfig(constant.NginxScopeServer, []dto.NginxParam{{Name: "include", Params: []string{includePath}}}, &website); err != nil {
|
||||
_ = fileOp.WriteFile(absolutePath, bytes.NewReader(oldRewriteContent), 0755)
|
||||
return err
|
||||
}
|
||||
website.Rewrite = req.Name
|
||||
return websiteRepo.Save(context.Background(), &website)
|
||||
}
|
||||
|
||||
func (w WebsiteService) GetRewriteConfig(req request.NginxRewriteReq) (*response.NginxRewriteRes, error) {
|
||||
website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var contentByte []byte
|
||||
if req.Name == "current" {
|
||||
nginxInstall, err := getAppInstallByKey(constant.AppOpenresty)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rewriteConfPath := path.Join(nginxInstall.GetPath(), "www", "sites", website.PrimaryDomain, "rewrite", fmt.Sprintf("%s.conf", website.PrimaryDomain))
|
||||
fileOp := files.NewFileOp()
|
||||
if fileOp.Stat(rewriteConfPath) {
|
||||
contentByte, err = fileOp.GetContent(rewriteConfPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rewriteFile := fmt.Sprintf("rewrite/%s.conf", strings.ToLower(req.Name))
|
||||
contentByte, err = nginx_conf.Rewrites.ReadFile(rewriteFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &response.NginxRewriteRes{
|
||||
Content: string(contentByte),
|
||||
}, err
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ var UpdateTableHost = &gormigrate.Migration{
|
||||
}
|
||||
|
||||
var UpdateTableWebsite = &gormigrate.Migration{
|
||||
ID: "20230406-update-table-website",
|
||||
ID: "20230414-update-table-website",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
return tx.AutoMigrate(&model.Website{})
|
||||
},
|
||||
|
@ -45,5 +45,8 @@ func (a *WebsiteRouter) InitWebsiteRouter(Router *gin.RouterGroup) {
|
||||
groupRouter.GET("/php/config/:id", baseApi.GetWebsitePHPConfig)
|
||||
groupRouter.POST("/php/config", baseApi.UpdateWebsitePHPConfig)
|
||||
groupRouter.POST("/php/update", baseApi.UpdatePHPFile)
|
||||
|
||||
groupRouter.POST("/rewrite", baseApi.GetRewriteConfig)
|
||||
groupRouter.POST("/rewrite/update", baseApi.UpdateRewriteConfig)
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ var repeatKeys = map[string]struct {
|
||||
"if": {},
|
||||
"proxy_set_header": {},
|
||||
"location": {},
|
||||
"include": {},
|
||||
}
|
||||
|
||||
func IsRepeatKey(key string) bool {
|
||||
|
@ -8715,6 +8715,90 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/rewrite": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取伪静态配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website"
|
||||
],
|
||||
"summary": "Get rewrite conf",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.NginxRewriteReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/rewrite/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新伪静态配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website"
|
||||
],
|
||||
"summary": "Update rewrite conf",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.NginxRewriteUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [
|
||||
{
|
||||
"db": "websites",
|
||||
"input_colume": "id",
|
||||
"input_value": "websiteID",
|
||||
"isList": false,
|
||||
"output_colume": "primary_domain",
|
||||
"output_value": "domain"
|
||||
}
|
||||
],
|
||||
"bodyKeys": [
|
||||
"websiteID"
|
||||
],
|
||||
"formatEN": "Nginx conf rewrite update [domain]",
|
||||
"formatZH": "伪静态配置修改 [domain]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -11830,9 +11914,15 @@ const docTemplate = `{
|
||||
"proxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxyType": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"rewrite": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtimeID": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -12404,6 +12494,40 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxRewriteReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"websiteId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxRewriteUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"content",
|
||||
"name",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"websiteId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxScopeReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@ -13402,9 +13526,15 @@ const docTemplate = `{
|
||||
"proxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxyType": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"rewrite": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtimeID": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -8708,6 +8708,90 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/rewrite": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "获取伪静态配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website"
|
||||
],
|
||||
"summary": "Get rewrite conf",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.NginxRewriteReq"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/rewrite/update": {
|
||||
"post": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "更新伪静态配置",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Website"
|
||||
],
|
||||
"summary": "Update rewrite conf",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "request",
|
||||
"name": "request",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/request.NginxRewriteUpdate"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK"
|
||||
}
|
||||
},
|
||||
"x-panel-log": {
|
||||
"BeforeFuntions": [
|
||||
{
|
||||
"db": "websites",
|
||||
"input_colume": "id",
|
||||
"input_value": "websiteID",
|
||||
"isList": false,
|
||||
"output_colume": "primary_domain",
|
||||
"output_value": "domain"
|
||||
}
|
||||
],
|
||||
"bodyKeys": [
|
||||
"websiteID"
|
||||
],
|
||||
"formatEN": "Nginx conf rewrite update [domain]",
|
||||
"formatZH": "伪静态配置修改 [domain]",
|
||||
"paramKeys": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"/websites/search": {
|
||||
"post": {
|
||||
"security": [
|
||||
@ -11823,9 +11907,15 @@
|
||||
"proxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxyType": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"rewrite": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtimeID": {
|
||||
"type": "integer"
|
||||
},
|
||||
@ -12397,6 +12487,40 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxRewriteReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"websiteId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxRewriteUpdate": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"content",
|
||||
"name",
|
||||
"websiteId"
|
||||
],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"websiteId": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"request.NginxScopeReq": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@ -13395,9 +13519,15 @@
|
||||
"proxy": {
|
||||
"type": "string"
|
||||
},
|
||||
"proxyType": {
|
||||
"type": "string"
|
||||
},
|
||||
"remark": {
|
||||
"type": "string"
|
||||
},
|
||||
"rewrite": {
|
||||
"type": "string"
|
||||
},
|
||||
"runtimeID": {
|
||||
"type": "integer"
|
||||
},
|
||||
|
@ -1750,8 +1750,12 @@ definitions:
|
||||
type: string
|
||||
proxy:
|
||||
type: string
|
||||
proxyType:
|
||||
type: string
|
||||
remark:
|
||||
type: string
|
||||
rewrite:
|
||||
type: string
|
||||
runtimeID:
|
||||
type: integer
|
||||
status:
|
||||
@ -2133,6 +2137,29 @@ definitions:
|
||||
required:
|
||||
- websiteId
|
||||
type: object
|
||||
request.NginxRewriteReq:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
websiteId:
|
||||
type: integer
|
||||
required:
|
||||
- name
|
||||
- websiteId
|
||||
type: object
|
||||
request.NginxRewriteUpdate:
|
||||
properties:
|
||||
content:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
websiteId:
|
||||
type: integer
|
||||
required:
|
||||
- content
|
||||
- name
|
||||
- websiteId
|
||||
type: object
|
||||
request.NginxScopeReq:
|
||||
properties:
|
||||
scope:
|
||||
@ -2799,8 +2826,12 @@ definitions:
|
||||
type: string
|
||||
proxy:
|
||||
type: string
|
||||
proxyType:
|
||||
type: string
|
||||
remark:
|
||||
type: string
|
||||
rewrite:
|
||||
type: string
|
||||
runtimeID:
|
||||
type: integer
|
||||
runtimeName:
|
||||
@ -8398,6 +8429,59 @@ paths:
|
||||
formatEN: Nginx conf update [domain]
|
||||
formatZH: php 配置修改 [domain]
|
||||
paramKeys: []
|
||||
/websites/rewrite:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 获取伪静态配置
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.NginxRewriteReq'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Get rewrite conf
|
||||
tags:
|
||||
- Website
|
||||
/websites/rewrite/update:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: 更新伪静态配置
|
||||
parameters:
|
||||
- description: request
|
||||
in: body
|
||||
name: request
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/request.NginxRewriteUpdate'
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: Update rewrite conf
|
||||
tags:
|
||||
- Website
|
||||
x-panel-log:
|
||||
BeforeFuntions:
|
||||
- db: websites
|
||||
input_colume: id
|
||||
input_value: websiteID
|
||||
isList: false
|
||||
output_colume: primary_domain
|
||||
output_value: domain
|
||||
bodyKeys:
|
||||
- websiteID
|
||||
formatEN: Nginx conf rewrite update [domain]
|
||||
formatZH: 伪静态配置修改 [domain]
|
||||
paramKeys: []
|
||||
/websites/search:
|
||||
post:
|
||||
consumes:
|
||||
|
@ -1,6 +1,7 @@
|
||||
package nginx_conf
|
||||
|
||||
import (
|
||||
"embed"
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
@ -15,3 +16,6 @@ var Index []byte
|
||||
|
||||
//go:embed index.php
|
||||
var IndexPHP []byte
|
||||
|
||||
//go:embed rewrite/*
|
||||
var Rewrites embed.FS
|
||||
|
6
cmd/server/nginx_conf/rewrite/crmeb.conf
Normal file
6
cmd/server/nginx_conf/rewrite/crmeb.conf
Normal file
@ -0,0 +1,6 @@
|
||||
location / {
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /index.php?s=/$1 last;
|
||||
break;
|
||||
}
|
||||
}
|
5
cmd/server/nginx_conf/rewrite/dabr.conf
Normal file
5
cmd/server/nginx_conf/rewrite/dabr.conf
Normal file
@ -0,0 +1,5 @@
|
||||
location / {
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^/(.*)$ /index.php?q=$1 last;
|
||||
}
|
||||
}
|
7
cmd/server/nginx_conf/rewrite/dbshop.conf
Normal file
7
cmd/server/nginx_conf/rewrite/dbshop.conf
Normal file
@ -0,0 +1,7 @@
|
||||
location /{
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
}
|
||||
|
||||
location ~ \.htaccess{
|
||||
deny all;
|
||||
}
|
10
cmd/server/nginx_conf/rewrite/dedecms.conf
Normal file
10
cmd/server/nginx_conf/rewrite/dedecms.conf
Normal file
@ -0,0 +1,10 @@
|
||||
rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
|
||||
rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
|
||||
rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
|
||||
rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
|
||||
rewrite "^/plus/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
|
||||
rewrite "^/plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
|
||||
rewrite "^/plus/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
|
||||
rewrite "^/plus/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
|
||||
rewrite "^/tags.html$" /tags.php last;
|
||||
rewrite "^/tag-([0-9]+)-([0-9]+)\.html$" /tags.php?/$1/$2/ last;
|
0
cmd/server/nginx_conf/rewrite/default.conf
Normal file
0
cmd/server/nginx_conf/rewrite/default.conf
Normal file
7
cmd/server/nginx_conf/rewrite/discuz.conf
Normal file
7
cmd/server/nginx_conf/rewrite/discuz.conf
Normal file
@ -0,0 +1,7 @@
|
||||
location / {
|
||||
rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;
|
||||
rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;
|
||||
rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page%3D$3&page=$2 last;
|
||||
rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;
|
||||
rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;
|
||||
}
|
12
cmd/server/nginx_conf/rewrite/discuzx.conf
Normal file
12
cmd/server/nginx_conf/rewrite/discuzx.conf
Normal file
@ -0,0 +1,12 @@
|
||||
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
|
||||
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
|
||||
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
|
||||
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
|
||||
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
|
||||
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
|
||||
if (!-e $request_filename) {
|
||||
return 404;
|
||||
}
|
14
cmd/server/nginx_conf/rewrite/discuzx2.conf
Normal file
14
cmd/server/nginx_conf/rewrite/discuzx2.conf
Normal file
@ -0,0 +1,14 @@
|
||||
location /bbs/ {
|
||||
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
|
||||
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
|
||||
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
|
||||
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
|
||||
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
|
||||
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
|
||||
if (!-e $request_filename) {
|
||||
return 404;
|
||||
}
|
||||
}
|
15
cmd/server/nginx_conf/rewrite/discuzx3.conf
Normal file
15
cmd/server/nginx_conf/rewrite/discuzx3.conf
Normal file
@ -0,0 +1,15 @@
|
||||
location / {
|
||||
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
|
||||
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
|
||||
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
|
||||
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
|
||||
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last;
|
||||
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
|
||||
if (!-e $request_filename) {
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
3
cmd/server/nginx_conf/rewrite/drupal.conf
Normal file
3
cmd/server/nginx_conf/rewrite/drupal.conf
Normal file
@ -0,0 +1,3 @@
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^/(.*)$ /index.php?q=$1 last;
|
||||
}
|
32
cmd/server/nginx_conf/rewrite/ecshop.conf
Normal file
32
cmd/server/nginx_conf/rewrite/ecshop.conf
Normal file
@ -0,0 +1,32 @@
|
||||
if (!-e $request_filename)
|
||||
{
|
||||
rewrite "^/index\.html" /index.php last;
|
||||
rewrite "^/category$" /index.php last;
|
||||
rewrite "^/feed-c([0-9]+)\.xml$" /feed.php?cat=$1 last;
|
||||
rewrite "^/feed-b([0-9]+)\.xml$" /feed.php?brand=$1 last;
|
||||
rewrite "^/feed\.xml$" /feed.php last;
|
||||
rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 last;
|
||||
rewrite "^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$" /category.php?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 last;
|
||||
rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3&sort=$4&order=$5 last;
|
||||
rewrite "^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2&page=$3 last;
|
||||
rewrite "^/category-([0-9]+)-b([0-9]+)(.*)\.html$" /category.php?id=$1&brand=$2 last;
|
||||
rewrite "^/category-([0-9]+)(.*)\.html$" /category.php?id=$1 last;
|
||||
rewrite "^/goods-([0-9]+)(.*)\.html" /goods.php?id=$1 last;
|
||||
rewrite "^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /article_cat.php?id=$1&page=$2&sort=$3&order=$4 last;
|
||||
rewrite "^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$" /article_cat.php?id=$1&page=$2 last;
|
||||
rewrite "^/article_cat-([0-9]+)(.*)\.html$" /article_cat.php?id=$1 last;
|
||||
rewrite "^/article-([0-9]+)(.*)\.html$" /article.php?id=$1 last;
|
||||
rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html" /brand.php?id=$1&cat=$2&page=$3&sort=$4&order=$5 last;
|
||||
rewrite "^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2&page=$3 last;
|
||||
rewrite "^/brand-([0-9]+)-c([0-9]+)(.*)\.html" /brand.php?id=$1&cat=$2 last;
|
||||
rewrite "^/brand-([0-9]+)(.*)\.html" /brand.php?id=$1 last;
|
||||
rewrite "^/tag-(.*)\.html" /search.php?keywords=$1 last;
|
||||
rewrite "^/snatch-([0-9]+)\.html$" /snatch.php?id=$1 last;
|
||||
rewrite "^/group_buy-([0-9]+)\.html$" /group_buy.php?act=view&id=$1 last;
|
||||
rewrite "^/auction-([0-9]+)\.html$" /auction.php?act=view&id=$1 last;
|
||||
rewrite "^/exchange-id([0-9]+)(.*)\.html$" /exchange.php?id=$1&act=view last;
|
||||
rewrite "^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 last;
|
||||
rewrite ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2&sort=$3&order=$4 last;
|
||||
rewrite "^/exchange-([0-9]+)-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1&page=$2 last;
|
||||
rewrite "^/exchange-([0-9]+)(.*)\.html$" /exchange.php?cat_id=$1 last;
|
||||
}
|
8
cmd/server/nginx_conf/rewrite/edusoho.conf
Normal file
8
cmd/server/nginx_conf/rewrite/edusoho.conf
Normal file
@ -0,0 +1,8 @@
|
||||
location / {
|
||||
index app.php;
|
||||
try_files $uri @rewriteapp;
|
||||
}
|
||||
|
||||
location @rewriteapp {
|
||||
rewrite ^(.*)$ /app.php/$1 last;
|
||||
}
|
7
cmd/server/nginx_conf/rewrite/emlog.conf
Normal file
7
cmd/server/nginx_conf/rewrite/emlog.conf
Normal file
@ -0,0 +1,7 @@
|
||||
location / {
|
||||
index index.php index.html;
|
||||
if (!-e $request_filename)
|
||||
{
|
||||
rewrite ^/(.*)$ /index.php last;
|
||||
}
|
||||
}
|
8
cmd/server/nginx_conf/rewrite/empirecms.conf
Normal file
8
cmd/server/nginx_conf/rewrite/empirecms.conf
Normal file
@ -0,0 +1,8 @@
|
||||
rewrite ^([^\.]*)/listinfo-(.+?)-(.+?)\.html$ $1/e/action/ListInfo/index.php?classid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/showinfo-(.+?)-(.+?)-(.+?)\.html$ $1/e/action/ShowInfo.php?classid=$2&id=$3&page=$4 last;
|
||||
rewrite ^([^\.]*)/infotype-(.+?)-(.+?)\.html$ $1/e/action/InfoType/index.php?ttid=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/tags-(.+?)-(.+?)\.html$ $1/e/tags/index.php?tagname=$2&page=$3 last;
|
||||
rewrite ^([^\.]*)/comment-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)-(.+?)\.html$ $1/e/pl/index\.php\?doaction=$2&classid=$3&id=$4&page=$5&myorder=$6&tempid=$7 last;
|
||||
if (!-e $request_filename) {
|
||||
return 404;
|
||||
}
|
3
cmd/server/nginx_conf/rewrite/laravel5.conf
Normal file
3
cmd/server/nginx_conf/rewrite/laravel5.conf
Normal file
@ -0,0 +1,3 @@
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
5
cmd/server/nginx_conf/rewrite/maccms.conf
Normal file
5
cmd/server/nginx_conf/rewrite/maccms.conf
Normal file
@ -0,0 +1,5 @@
|
||||
rewrite ^/vod-(.*)$ /index.php?m=vod-$1 break;
|
||||
rewrite ^/art-(.*)$ /index.php?m=art-$1 break;
|
||||
rewrite ^/gbook-(.*)$ /index.php?m=gbook-$1 break;
|
||||
rewrite ^/label-(.*)$ /index.php?m=label-$1 break;
|
||||
rewrite ^/map-(.*)$ /index.php?m=map-$1 break;
|
6
cmd/server/nginx_conf/rewrite/mvc.conf
Normal file
6
cmd/server/nginx_conf/rewrite/mvc.conf
Normal file
@ -0,0 +1,6 @@
|
||||
location /{
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /index.php/$1 last;
|
||||
break;
|
||||
}
|
||||
}
|
6
cmd/server/nginx_conf/rewrite/niushop.conf
Normal file
6
cmd/server/nginx_conf/rewrite/niushop.conf
Normal file
@ -0,0 +1,6 @@
|
||||
location / {
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /index.php?s=$1 last;
|
||||
break;
|
||||
}
|
||||
}
|
9
cmd/server/nginx_conf/rewrite/phpcms.conf
Normal file
9
cmd/server/nginx_conf/rewrite/phpcms.conf
Normal file
@ -0,0 +1,9 @@
|
||||
location / {
|
||||
###以下为PHPCMS 伪静态化rewrite法则
|
||||
rewrite ^(.*)show-([0-9]+)-([0-9]+)\.html$ $1/show.php?itemid=$2&page=$3;
|
||||
rewrite ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$2&page=$3;
|
||||
rewrite ^(.*)show-([0-9]+)\.html$ $1/show.php?specialid=$2;
|
||||
####以下为PHPWind 伪静态化rewrite法则
|
||||
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
|
||||
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
|
||||
}
|
4
cmd/server/nginx_conf/rewrite/phpwind.conf
Normal file
4
cmd/server/nginx_conf/rewrite/phpwind.conf
Normal file
@ -0,0 +1,4 @@
|
||||
location / {
|
||||
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
|
||||
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
|
||||
}
|
16
cmd/server/nginx_conf/rewrite/sablog.conf
Normal file
16
cmd/server/nginx_conf/rewrite/sablog.conf
Normal file
@ -0,0 +1,16 @@
|
||||
location / {
|
||||
rewrite "^/date/([0-9]{6})/?([0-9]+)?/?$" /index.php?action=article&setdate=$1&page=$2 last;
|
||||
rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;
|
||||
rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;
|
||||
rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;
|
||||
rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;
|
||||
rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;
|
||||
rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;
|
||||
rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;
|
||||
rewrite ^/rss/([0-9]+)?/?$ /rss.php?cid=$1 last;
|
||||
rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;
|
||||
rewrite ^/uid/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&uid=$1&page=$2 last;
|
||||
rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;
|
||||
rewrite sitemap.xml sitemap.php last;
|
||||
rewrite ^(.*)/([0-9a-zA-Z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last;
|
||||
}
|
11
cmd/server/nginx_conf/rewrite/seacms.conf
Normal file
11
cmd/server/nginx_conf/rewrite/seacms.conf
Normal file
@ -0,0 +1,11 @@
|
||||
location / {
|
||||
rewrite ^/frim/index(.+?)\.html$ /list/index.php?$1 last;
|
||||
rewrite ^/movie/index(.+?)\.html$ /detail/index.php?$1 last;
|
||||
rewrite ^/play/([0-9]+)-([0-9]+)-([0-9]+)\.html$ /video/index.php?$1-$2-$3 last;
|
||||
rewrite ^/topic/index(.+?)\.html$ /topic/index.php?$1 last;
|
||||
rewrite ^/topiclist/index(.+?).html$ /topiclist/index.php?$1 last;
|
||||
rewrite ^/index\.html$ index.php permanent;
|
||||
rewrite ^/news\.html$ news/ permanent;
|
||||
rewrite ^/part/index(.+?)\.html$ /articlelist/index.php?$1 last;
|
||||
rewrite ^/article/index(.+?)\.html$ /article/index.php?$1 last;
|
||||
}
|
5
cmd/server/nginx_conf/rewrite/shopex.conf
Normal file
5
cmd/server/nginx_conf/rewrite/shopex.conf
Normal file
@ -0,0 +1,5 @@
|
||||
location / {
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^/(.+\.(html|xml|json|htm|php|jsp|asp|shtml))$ /index.php?$1 last;
|
||||
}
|
||||
}
|
14
cmd/server/nginx_conf/rewrite/shopwind.conf
Normal file
14
cmd/server/nginx_conf/rewrite/shopwind.conf
Normal file
@ -0,0 +1,14 @@
|
||||
location / {
|
||||
#Redirect everything that isn't a real file to index.php
|
||||
try_files $uri $uri/ /index.php$is_args$args;
|
||||
}
|
||||
#If you want a single domain name at the front and back ends
|
||||
location /admin {
|
||||
try_files $uri $uri/ /admin/index.php$is_args$args;
|
||||
}
|
||||
location /mobile {
|
||||
try_files $uri $uri/ /mobile/index.php$is_args$args;
|
||||
}
|
||||
location /api {
|
||||
try_files $uri $uri/ /api/index.php$is_args$args;
|
||||
}
|
8
cmd/server/nginx_conf/rewrite/thinkphp.conf
Normal file
8
cmd/server/nginx_conf/rewrite/thinkphp.conf
Normal file
@ -0,0 +1,8 @@
|
||||
location ~* (runtime|application)/ {
|
||||
return 403;
|
||||
}
|
||||
location / {
|
||||
if (!-e $request_filename){
|
||||
rewrite ^(.*)$ /index.php?s=$1 last; break;
|
||||
}
|
||||
}
|
3
cmd/server/nginx_conf/rewrite/typecho.conf
Normal file
3
cmd/server/nginx_conf/rewrite/typecho.conf
Normal file
@ -0,0 +1,3 @@
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /index.php$1 last;
|
||||
}
|
5
cmd/server/nginx_conf/rewrite/typecho2.conf
Normal file
5
cmd/server/nginx_conf/rewrite/typecho2.conf
Normal file
@ -0,0 +1,5 @@
|
||||
location /typecho/ {
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^(.*)$ /typecho/index.php$1 last;
|
||||
}
|
||||
}
|
6
cmd/server/nginx_conf/rewrite/wordpress.conf
Normal file
6
cmd/server/nginx_conf/rewrite/wordpress.conf
Normal file
@ -0,0 +1,6 @@
|
||||
location /
|
||||
{
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
}
|
||||
|
||||
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
|
6
cmd/server/nginx_conf/rewrite/wp2.conf
Normal file
6
cmd/server/nginx_conf/rewrite/wp2.conf
Normal file
@ -0,0 +1,6 @@
|
||||
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
|
||||
if (!-e $request_filename){
|
||||
rewrite ^.+?(/wp-.*) $1 last;
|
||||
rewrite ^.+?(/.*\.php)$ $1 last;
|
||||
rewrite ^ /index.php last;
|
||||
}
|
9
cmd/server/nginx_conf/rewrite/zblog.conf
Normal file
9
cmd/server/nginx_conf/rewrite/zblog.conf
Normal file
@ -0,0 +1,9 @@
|
||||
if (-f $request_filename/index.html){
|
||||
rewrite (.*) $1/index.html break;
|
||||
}
|
||||
if (-f $request_filename/index.php){
|
||||
rewrite (.*) $1/index.php;
|
||||
}
|
||||
if (!-f $request_filename){
|
||||
rewrite (.*) /index.php;
|
||||
}
|
@ -17,6 +17,7 @@ export namespace Website {
|
||||
appinstall?: NewAppInstall;
|
||||
webSiteSSL: SSL;
|
||||
runtimeID: number;
|
||||
rewrite: string;
|
||||
}
|
||||
|
||||
export interface WebsiteDTO extends Website {
|
||||
@ -278,4 +279,19 @@ export namespace Website {
|
||||
content: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
export interface RewriteReq {
|
||||
websiteID: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface RewriteRes {
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface RewriteUpdate {
|
||||
websiteID: number;
|
||||
name: string;
|
||||
content: string;
|
||||
}
|
||||
}
|
||||
|
@ -170,3 +170,11 @@ export const UpdatePHPConfig = (req: Website.PHPConfigUpdate) => {
|
||||
export const UpdatePHPFile = (req: Website.PHPUpdate) => {
|
||||
return http.post<any>(`/websites/php/update`, req);
|
||||
};
|
||||
|
||||
export const GetRewriteConfig = (req: Website.RewriteReq) => {
|
||||
return http.post<Website.RewriteRes>(`/websites/rewrite`, req);
|
||||
};
|
||||
|
||||
export const UpdateRewriteConfig = (req: Website.RewriteUpdate) => {
|
||||
return http.post<any>(`/websites/rewrite/update`, req);
|
||||
};
|
||||
|
@ -78,3 +78,35 @@ export const Languages = [
|
||||
value: ['css'],
|
||||
},
|
||||
];
|
||||
|
||||
export const Rewrites = [
|
||||
'default',
|
||||
'wordpress',
|
||||
'wp2',
|
||||
'typecho',
|
||||
'typecho2',
|
||||
'thinkphp',
|
||||
'laravel5',
|
||||
'discuz',
|
||||
'discuzx',
|
||||
'discuzx2',
|
||||
'discuzx3',
|
||||
'EduSoho',
|
||||
'EmpireCMS',
|
||||
'ShopWind',
|
||||
'crmeb',
|
||||
'dabr',
|
||||
'dbshop',
|
||||
'dedecms',
|
||||
'drupal',
|
||||
'ecshop',
|
||||
'emlog',
|
||||
'maccms',
|
||||
'mvc',
|
||||
'niushop',
|
||||
'phpcms',
|
||||
'sablog',
|
||||
'seacms',
|
||||
'shopex',
|
||||
'zblog',
|
||||
];
|
||||
|
@ -1166,6 +1166,11 @@ const message = {
|
||||
updateConfig: 'Update Config',
|
||||
isOn: 'On',
|
||||
isOff: 'Off',
|
||||
rewrite: 'Pseudo Static',
|
||||
rewriteMode: 'Scheme',
|
||||
current: 'Current',
|
||||
rewriteHelper:
|
||||
'If the website cannot be accessed normally after setting pseudo-static, please try to set it back to default',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Short tag support',
|
||||
|
@ -1159,6 +1159,10 @@ const message = {
|
||||
updateConfig: '配置修改',
|
||||
isOn: '开启',
|
||||
isOff: '关闭',
|
||||
rewrite: '伪静态',
|
||||
rewriteMode: '方案',
|
||||
current: '当前',
|
||||
rewriteHelper: '若设置伪静态后,网站无法正常访问,请尝试设置回default',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短标签支持',
|
||||
|
@ -191,6 +191,7 @@ const searchApp = (appId: number) => {
|
||||
const changeApp = (appId: number) => {
|
||||
for (const app of apps.value) {
|
||||
if (app.id === appId) {
|
||||
initParam.value = false;
|
||||
getApp(app.key, mode.value);
|
||||
break;
|
||||
}
|
||||
|
@ -15,14 +15,17 @@
|
||||
<el-tab-pane :label="'HTTPS'">
|
||||
<HTTPS :id="id" v-if="tabIndex == '4'"></HTTPS>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('website.rewrite')">
|
||||
<Rewrite :id="id" v-if="tabIndex == '5'"></Rewrite>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('website.other')">
|
||||
<Other :id="id" v-if="tabIndex == '5'"></Other>
|
||||
<Other :id="id" v-if="tabIndex == '6'"></Other>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="Basic">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import Doamin from './domain/index.vue';
|
||||
import Default from './default-doc/index.vue';
|
||||
@ -30,6 +33,7 @@ import LimitConn from './limit-conn/index.vue';
|
||||
import Other from './other/index.vue';
|
||||
import HTTPS from './https/index.vue';
|
||||
import SitePath from './site-folder/index.vue';
|
||||
import Rewrite from './rewrite/index.vue';
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
@ -42,5 +46,7 @@ const id = computed(() => {
|
||||
return props.id;
|
||||
});
|
||||
|
||||
let tabIndex = ref('0');
|
||||
const tabIndex = ref('0');
|
||||
|
||||
onMounted(() => {});
|
||||
</script>
|
||||
|
@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<div v-loading="loading">
|
||||
<el-form-item :label="$t('website.rewriteMode')">
|
||||
<el-select v-model="req.name" filterable @change="getRewriteConfig(req.name)">
|
||||
<el-option :label="$t('website.current')" :value="'current'"></el-option>
|
||||
<el-option
|
||||
v-for="(rewrite, index) in Rewrites"
|
||||
:key="index"
|
||||
:label="rewrite"
|
||||
:value="rewrite"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<codemirror
|
||||
:autofocus="true"
|
||||
placeholder=""
|
||||
:indent-with-tab="true"
|
||||
:tabSize="4"
|
||||
style="margin-top: 10px; height: 300px"
|
||||
:lineWrapping="true"
|
||||
:matchBrackets="true"
|
||||
theme="cobalt"
|
||||
:styleActiveLine="true"
|
||||
:extensions="extensions"
|
||||
v-model="content"
|
||||
/>
|
||||
<div style="margin-top: 10px">
|
||||
<el-form-item>
|
||||
<el-alert :title="$t('website.rewriteHelper')" type="info" :closable="false" />
|
||||
</el-form-item>
|
||||
<el-button type="primary" @click="submit()">
|
||||
{{ $t('nginx.saveAndReload') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, reactive, ref } from 'vue';
|
||||
import { Codemirror } from 'vue-codemirror';
|
||||
import { oneDark } from '@codemirror/theme-one-dark';
|
||||
import { StreamLanguage } from '@codemirror/language';
|
||||
import { nginx } from '@codemirror/legacy-modes/mode/nginx';
|
||||
import { GetWebsite, GetRewriteConfig, UpdateRewriteConfig } from '@/api/modules/website';
|
||||
import { Rewrites } from '@/global/mimetype';
|
||||
import { MsgSuccess } from '@/utils/message';
|
||||
import i18n from '@/lang';
|
||||
|
||||
const loading = ref(false);
|
||||
const content = ref('');
|
||||
const extensions = [StreamLanguage.define(nginx), oneDark];
|
||||
|
||||
const props = defineProps({
|
||||
id: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
});
|
||||
|
||||
const id = computed(() => {
|
||||
return props.id;
|
||||
});
|
||||
|
||||
const req = reactive({
|
||||
websiteID: id.value,
|
||||
name: 'default',
|
||||
});
|
||||
|
||||
const update = reactive({
|
||||
websiteID: id.value,
|
||||
content: '',
|
||||
name: '',
|
||||
});
|
||||
|
||||
const getRewriteConfig = async (rewrite: string) => {
|
||||
loading.value = true;
|
||||
req.name = rewrite;
|
||||
req.websiteID = id.value;
|
||||
try {
|
||||
const res = await GetRewriteConfig(req);
|
||||
content.value = res.data.content;
|
||||
} catch (error) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const submit = async () => {
|
||||
update.name = req.name;
|
||||
update.websiteID = id.value;
|
||||
update.content = content.value;
|
||||
loading.value = true;
|
||||
try {
|
||||
await UpdateRewriteConfig(update);
|
||||
MsgSuccess(i18n.global.t('commons.msg.updateSuccess'));
|
||||
} catch (error) {
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
GetWebsite(id.value).then((res) => {
|
||||
const name = res.data.rewrite == '' ? 'default' : 'current';
|
||||
if (name === 'current') {
|
||||
req.name = 'current';
|
||||
}
|
||||
getRewriteConfig(name);
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user