我有以下configuration,现在将/create_user/check重写为/create_user.php?check=true 。 location / { try_files $uri $uri/ @ext-php; } location @ext-php { rewrite ^(.*)/create_user/check$ $1/create_user.php?check=true last; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 另外,我想将使用“create_user.php?check = true”版本的用户redirect到无扩展版本。 什么是最好的方式来configuration? 是在服务器块(如下)重写一个好办法做到这一点? rewrite ^(.*)/create_user.php?check=true$ $1/create_user/check redirect; 更新:以下configuration更改工作:添加一个地图块: map $query_string $updated_path { "check=true" "check"; } 并将服务器块中的重写更改为: rewrite ^(.*/create_user).php$ $1/$updated_path? redirect;
用Nginx作为反向代理,你如何在cookie中添加samesite = strict或samesite = lax?
这个问题已经被多次回答了,但是在我的情况中却有一个转折点。 我有一个在端口3000上运行的节点应用程序。我正在使用nginx来反向代理。 现在应用程序只有在最后有一个斜线的时候才起作用。 所以这个工程: https://example.com/main/site/react/ : https://example.com/main/site/react/ 这不: https://example.com/main/site/react : https://example.com/main/site/react 这是我正在使用的configuration: location /main/site/react { error_log /var/log/nginx/app.error.log; rewrite ^/main/site/react/(?:|[\w\/]+)(\/static.*)$ $1 break; rewrite ^/main/site/react/?(.*)$ /$1 break; proxy_pass http://127.0.0.1:3000/; } 在检查其他相关问题后,添加以下重写规则(在error_log之后)为我工作: rewrite ^(.*[^/])$ $1/ permanent; 上面的规则呈现我的节点应用程序,但它失败了我的静态资源。 我有一些静态资源重写哪些不工作。 所以这个URL不起作用: https://example.com/main/site/react/static/js/bundle.js : https://example.com/main/site/react/static/js/bundle.js 。 它总是呈现索引HTML页面。
我需要将以下规则从apache转换为nginx: RewriteCond %{QUERY_STRING} id=([^&]*) [NC,OR] RewriteCond %{QUERY_STRING} daily=([^&]*) [NC] RewriteCond %{REQUEST_URI} !mobSpecCycle [NC] RewriteCond %{REQUEST_URI} !mobSpecTheme [NC] RewriteRule ^rss\/mobSpec([^\/]+)/?$ /rss/mobSpec$1/mobSpec$1_%1.html [QSA,NC,L] 例如重写 / RSS / mobSpecArticle /?ID = 26422 成 /rss/mobSpecArticle/mobSpecArticle_26422.html 我开始如下 if ($args ~ id=([^&]*)|daily=([^&]*)) { rewrite ^/rss\/mobSpec([^\/]+)/?$ /rss/mobSpec$1/mobSpec$1_$2.html last; } 但是我不知道如何在重写规则中取消id =([^&] *)? 我把$ 2放在那里,但它不工作… apache具有%1从RewriteCond反向引用匹配。 如何在后面的重写中从nginx的if()返回引用匹配? 任何想法如何可以添加最后两个条件? RewriteCond %{REQUEST_URI} !mobSpecCycle [NC] RewriteCond […]
当试图使phpmyadmin在我的Nginx服务器上工作时,它会将请求https://fellowshipmedia.eu/phpmyadmin重写为https://fellowshipmedia.eu/index.php 。 我试着用'rewrite_log'和'debug'标志来读取error.log,但是日志对我来说很难理解。 我可以看到,在某个点上path的前缀被删除,但为什么? 这是nginx conf文件的一部分: server { listen 443 ssl http2; listen [::]:443 ssl http2; ssl_certificate /etc/letsencrypt/live/fellowshipmedia.eu/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/fellowshipmedia.eu/privkey.pem; include snippets/ssl-params.conf; server_name fellowshipmedia.eu; root /usr/share/nginx/html/fellowshipmediaeu/httpsdocs/; index index.php index.html index.htm ; location / { try_files $uri $uri/ /index.php?page=$uri; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } } 这是access.log: 86.83.94.220 – – [10/Jun/2017:07:24:10 +0200] […]
请帮我在Nginx中创build一个重写规则,这样这个URL https://subdomain.domain.com/api被重写到https://subdomain-api.domain.com 提前致谢。
我想要在单个域下部署多个asp.net mvc应用程序,但我不确定在IIS中执行此操作的正确方法是什么。 我希望他们有以下的url www.domain.com/something-from-app1 www.domain.com/something-from-app2 我脑子里有几个选项,但不确定他们是否会在实际中工作。 将每个应用程序部署为子域,然后进行重写 app1.domain.com/something to www.domain.com/something-from-app1 app2.domain.com/something to www.domain.com/something-from-app2 在域的虚拟文件夹下部署每个应用程序,然后进行重写 www.domain.com/site/app1/something to www.domain.com/something-from-app1 www.domain.com/site/app2/something to www.domain.com/something-from-app2 两种select都只是纯粹的理论,我想知道这两种情况下,我解释abovre工作吗?
我在单独的文件夹中运行了几个SPA以及一些静态文件。 结构如下: | |- index.html |- foobar.html |—- SPA1/ | |- index.html | |—- SPA1_1/ | |- index.html |—- SPA2/ |- index.html 预期的行为是: 所有/SPA1/SPA1_1/foo/bar与SPA1/SPA1_1/index.html 用SPAx/index.html服务所有的SPAx/foo/bar 用/index.html服务/not_exist 用/foobar.html提供/foobar.html 总之,我希望nginx按顺序尝试以下path: $uri $uri最亲密的父母 有没有什么办法可以达到这个目的而不需要为每个SPA目录指定规则?
我正在使用nginx 1.10.3来运行joomla 3.7.3,并且在清除尾部斜线时遇到了问题。 我打开了“search引擎友好的URL”,以及“使用URL重写”。 我在我的nginx conf文件中有这些东西: server { listen 80 default_server; listen [::]:80 default_server; root /var/www/folder; index index.php index.html index.htm default.html default.htm; rewrite ^/(.+)/$ /$1 permanent; server_name 000.000.00.000; server_name_in_redirect off; location / { try_files $uri $uri/ /index.php?$args; } location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ { return 403; error_page 403 /403_error.html; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass […]
我目前正在使用nginx重写来传递服务器variables。 我可以像这样传递一个variables: http://example.com/test : http://example.com/test ,它可以通过: http://example.com/?p=test : http://example.com/?p=test 。 我这样做: location / { rewrite ^/([^/\.]+)$ /?p=$1 break; } 现在我想能够使用子目录传递variables,以便映射发生像这样: http://example.com/profile/user1 => http://example.com/?p=user1 我想要有这样的多个规则,以便在同一个网站上,我也有一个像这样的规则: http://example.com/play/vid1 => http://example.com/?v=vid1 我试过这个,但没有奏效: location /profile/ { rewrite ^/([^/\.]+)$ /?p=$1 break; } location /play/ { rewrite ^/([^/\.]+)$ /?v=$1 break; } 我也尝试没有像后面的斜杠: location /profile { rewrite ^/([^/\.]+)$ /?p=$1 break; } location /play […]