# Regular Expression 正規化

## Regular Expression 正規化

<https://www.unicloud.com/analytics>

```
server {

    ...
    ...

    location ~ ^/analytics/.+\.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME /var/www/gpd.admin/analytics/public/index.php;
        include        fastcgi_params;
    }

    location ~^/analytics($|/.*) {
        alias       /var/www/gpd.admin/analytics/public/;
        index       index.php index.html index.htm;
        try_files $uri $uri/ /analytics/index.php;
    }

    ...
    ...
}
```

* \~ 大小写敏感匹配
* \~\* 大小写不敏感匹配
* ^ 開頭字元
* $ 結尾字元
* .+ 任意`1~N`字元
* () 一組 sub pattern
* \| 或是

![](https://lh6.googleusercontent.com/-HAMFz5IBnQI/VTmxNvuG_WI/AAAAAAAABRM/U6VboCN_uZU/w487-h164-no/documentroot.png)

## Question

如果訪問的網址是：

1. <https://www.unicloud.com/analytics/>
2. <https://www.unicloud.com/analytics/index.php>
3. <https://www.unicloud.com/analytics/index>
