删除前导斜线 NGINX
Remove leading slash NGINX
我的 URL 中有一个双斜杠(这不理想)。
所以我的应用程序在 //signup
被命中。
错误信息:
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET //signin""
是否要将其更改为 /signup
?
我已经在第一个位置块(捕获代理的那个)中尝试了以下内容。
也许类似于...
location /apps/phpauthentication/1 {
rewrite ^\//(.*)/$ / break;
try_files $uri /app_dev.php$is_args$args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last;
}
}
完整配置:
server {
listen 80;
server_name localhost;
root /srv/http/web;
index app_dev.php index.php index.html;
location /apps/phpauthentication/1 {
rewrite ^\//(.*)/$ /$uri permanent;
try_files $uri /app_dev.php$is_args$args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last;
}
}
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param APP_ENV dev;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV dev;
include fastcgi_params;
}
}
谢谢:)
我在处理以下内容时成功地在后端更改了 URI。
location /apps/phpauthentication/1 {
rewrite ^(.*)//(.*)$ // permanent; ##First matches double slash and rewrites
try_files $uri /app_dev.php$is_args$args; ##URI is now /apps/1/signup
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last; ## Matches all request that pass from above
}
现在浏览器中的 URL 永远不会改变,但后端服务器现在似乎有一个有效路径。
我的 URL 中有一个双斜杠(这不理想)。
所以我的应用程序在 //signup
被命中。
错误信息:
Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "No route found for "GET //signin""
是否要将其更改为 /signup
?
我已经在第一个位置块(捕获代理的那个)中尝试了以下内容。
也许类似于...
location /apps/phpauthentication/1 {
rewrite ^\//(.*)/$ / break;
try_files $uri /app_dev.php$is_args$args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last;
}
}
完整配置:
server {
listen 80;
server_name localhost;
root /srv/http/web;
index app_dev.php index.php index.html;
location /apps/phpauthentication/1 {
rewrite ^\//(.*)/$ /$uri permanent;
try_files $uri /app_dev.php$is_args$args;
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last;
}
}
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass app:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param APP_ENV dev;
include fastcgi_params;
}
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV dev;
include fastcgi_params;
}
}
谢谢:)
我在处理以下内容时成功地在后端更改了 URI。
location /apps/phpauthentication/1 {
rewrite ^(.*)//(.*)$ // permanent; ##First matches double slash and rewrites
try_files $uri /app_dev.php$is_args$args; ##URI is now /apps/1/signup
if (!-e $request_filename) {
rewrite ^/(.*)$ /app_dev.php last; ## Matches all request that pass from above
}
现在浏览器中的 URL 永远不会改变,但后端服务器现在似乎有一个有效路径。