需求是要有个性域名,如 user1.abc.com
nginx中,开启了反向代理
<code>rewrite ^/article/show/id/([0-9]+)/?$ /article/show/uid/$uid/id/$1 break; proxy_pass http://www.abc.com;</code>
这样浏览器中访问user1.abc.com/article/show/id/1 就不会跳转到www.abc.com/article/show/uid/user1/id/1了
获取当前页面的URL时获取到的是http://www.abc.com/article/show/uid/user1/id/1
<code>$url = "http://".$_SERVER['HTTP_HOST']; if(isset($_SERVER["REQUEST_URI"])){ $url .= $_SERVER["REQUEST_URI"]; }else{ $url .= $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; } echo $url;</code>
除了JS能不能用PHP获取当前浏览器的中URL或者说是反向代理之前的URL?
需求是要有个性域名,如 user1.abc.com
nginx中,开启了反向代理
<code>rewrite ^/article/show/id/([0-9]+)/?$ /article/show/uid/$uid/id/$1 break; proxy_pass http://www.abc.com;</code>
这样浏览器中访问user1.abc.com/article/show/id/1 就不会跳转到www.abc.com/article/show/uid/user1/id/1了
获取当前页面的URL时获取到的是http://www.abc.com/article/show/uid/user1/id/1
<code>$url = "http://".$_SERVER['HTTP_HOST']; if(isset($_SERVER["REQUEST_URI"])){ $url .= $_SERVER["REQUEST_URI"]; }else{ $url .= $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']; } echo $url;</code>
除了JS能不能用PHP获取当前浏览器的中URL或者说是反向代理之前的URL?
nginx 反代会自动把域名放到 headers 的 host 字段啊。