Nginx重定向试图访问文件夹的所有请求
如何重定向试图访问文件夹的所有请求 例如,我想重定向:Nginx重定向试图访问文件夹的所有请求,nginx,rewrite,Nginx,Rewrite,如何重定向试图访问文件夹的所有请求 例如,我想重定向: somedomain.com/folder/subfolder/index.html somedomain.com/folder/subfolder2/something.html somedomain.com/folder/subfolder3/somethingelse.html 到 我所尝试的: if ( $request_uri = "/folder/.*" ) { rewrite ^/(.*)$ http://domain
somedomain.com/folder/subfolder/index.html
somedomain.com/folder/subfolder2/something.html
somedomain.com/folder/subfolder3/somethingelse.html
到
我所尝试的:
if ( $request_uri = "/folder/.*" ) {
rewrite ^/(.*)$ http://domain2.com/embed.html permanent;
}
你只是无缘无故地使事情复杂化,不需要做if条件,你应该一直尝试
if ( $request_uri = "/folder/.*" ) {
rewrite ^/(.*)$ http://domain2.com/embed.html permanent;
}
location /folder { # this will match all subfolders and files
return 301 http://domain2.com/embed.html;
}