相关疑难解决方法(0)

如何在NGINX中重定向URL

我需要将每个http://test.com请求重定向到http://www.test.com.如何才能做到这一点.

在服务器块中我尝试添加

 rewrite ^/(.*) http://www.test.com/$1 permanent;
Run Code Online (Sandbox Code Playgroud)

但它在浏览器中说

  The page isn't redirecting properly

  Firefox has detected that the server is redirecting the request for 
  this address in a way that will never complete.
Run Code Online (Sandbox Code Playgroud)

我的服务器块看起来像

 server {
            listen       80;
            server_name  test.com;
            client_max_body_size   10M;
            client_body_buffer_size   128k;

            root       /home/test/test/public;
            passenger_enabled on;
            rails_env production;

            #rewrite ^/(.*) http://www.test.com/$1 permanent;
            #rewrite ^(.*)$ $scheme://www.test.com$1;

            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                    root   html;
            }
    }
Run Code Online (Sandbox Code Playgroud)

redirect nginx url-rewriting

134
推荐指数
4
解决办法
27万
查看次数

返回react-router-dom时浏览器历史记录不起作用

我们正在开发一个用 dotnet 编写的带有 Razor 视图(纯后端堆栈)的项目。我们计划将每个视图移至React用于react-router-dom处理客户端和服务器中的路由。

我们的想法是一页一页地移动,而不是大爆炸,因为该项目已经在生产中。

客户端路由器

import { Router } from 'react-router-dom'
import { createBrowserHistory, History } from 'history'

const history: History = createBrowserHistory({ basename: baseUrl })

<Router history={history}>
  <Switch>
      <Route path="/example" component={Example} />
      ...
   </Switch>
</Router>
Run Code Online (Sandbox Code Playgroud)

服务器路由器

import { StaticRouter } from 'react-router-dom'

<StaticRouter
 basename={basename}
 context={routerContext}
 location={params.location.path}
>
   <Switch>
      <Route path="/example" component={Example} />
      ...
   </Switch>
</StaticRouter>
Run Code Online (Sandbox Code Playgroud)

问题

/当我从(在 React 路由器中)导航到/example(在 .net 路由器中)然后尝试返回到 时/example,看起来没有转换到 React 路由器,并且浏览器历史记录保持在/

javascript reactjs react-router react-router-dom

5
推荐指数
1
解决办法
2084
查看次数

重新加载在 github 页面上发布的 Angular SPA 时找不到 404 文件

重新加载发布在 gh 页面上的 angular 应用程序时,我收到错误消息。错误是:

404
File not found.
The site configured at this address does not contain the requested file.
Run Code Online (Sandbox Code Playgroud)

我已经使用 ng build --prod 构建了我的应用程序。

Github 存储库: https : //github.com/chirag299051/IceAndFire

Github 页面: https : //chirag299051.github.io/IceAndFire/

我的 app.module.ts 文件包含:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';


import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';

import { RouterModule, Routes } from '@angular/router';
import { BookDetailsComponent } …
Run Code Online (Sandbox Code Playgroud)

github nginx github-pages angular ng-build

1
推荐指数
1
解决办法
845
查看次数