无法在nginx中重写url

时间:2015-01-14 20:13:47

标签: nginx url-rewriting rewrite

在文件/etc/nginx/sites-available/default中,我有以下代码:

server {
    listen 80 default; ## listen for ipv4; this line is default and implied
    listen [::]:80 default ipv6only=on; ## listen for ipv6

    # Make site accessible from http://localhost/
    server_name localhost;
    server_name_in_redirect off;

    charset utf-8;

    access_log  /usr/share/nginx/access.log;
    error_log   /usr/share/nginx/error.log;

    root /usr/share/nginx/www;
    index index.php index.html index.htm;

    location / {
        # First attempt to serve request as file, then
        # as directory, then trigger 404
        try_files $uri $uri/ =404;

        rewrite www.some-url.com break;    <----- added this line

        server_name_in_redirect off;
    }
 }

虽然我不确定这是否正确(我试过阅读ngx_http_rewrite_module的文档,但我仍然不能理解它......)

我想要的是任何网址指令上的任何听众; www.some-url.com&#34;在他的浏览器(我的自定义URL)。有人可以帮我解决这个问题吗?

0 个答案:

没有答案