1

基本上我有以下网址:

http://website.com/details.php?id=10&id=1

我想被改写成

http://website.com/details.customextension

我尝试添加以下行:

location /details {
  rewrite ^/details\.customextension$ /details.php?id=$1&hit=$2;
}

但是当我点击 details.php 链接时,它会将我重定向到 index.php。

这是 vhost 的 conf 文件:

    # You may add here your
# server {
#   ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##



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

    root /var/www/website/application;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name website.com www.website.com;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    # Logs
    access_log  /var/www/website/logs/website.access.log  main;

    error_log /var/www/website/logs/website.error.log ;

    # File uploads
    client_max_body_size 10M;
    client_body_buffer_size 128k;

    # Add www to all urls
    if ($host ~* ^([a-z0-9\-]+\.(be|fr|nl|de))$) {
    rewrite ^(.*)$ http://www.$host$1 permanent;
    }



    location / {
        expires 1d;
        # Note that nginx does not use .htaccess.
        # This will allow for SEF URL’s
        try_files $uri $uri/ /index.php?$args;

    }


        # Here we set up static files access and caching
        location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|

js)$ {
    access_log off;
    expires max;
        }

    location ~* /(admin|cache|include|install)/ {
    deny all;
    }

        error_page  404              /404.html;
        location = /404.html {  
    root   /usr/share/nginx/www;
    }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
    root   /usr/share/nginx/www;
    }

    proxy_cache_key "$host$request_uri$cookie_sessioncookie";

        # Send PHP scripts to FPM on 127.0.0.1:9000
        location ~ \.php$ {
              fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME /var/www/public$fastcgi_script_name;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
            fastcgi_intercept_errors on;
            include        fastcgi_params;
            expires 0d;
        }


}

我究竟做错了什么?谢谢!

4

0 回答 0