2016-03-24 26 views
1

www.mrmerch.com/TERMSとwww.mrmerch.com/termsの両方にアクセスしたいと考えています。私は現在、これを達成するために2つのサブフォルダを設定しています - 用語と用語。非効率的で間違っている、私は知っている。nginxの大文字と小文字を区別しないURL

ここは私の現在の設定です。最後の位置ブロックを追加しましたが、それでも正確に一致しないものはヒットできません(例:「利用規約」など)。どんな助けでも大歓迎です。ありがとう!

server { 
server_name www.mrmerch.com; 
return 301 $scheme://mrmerch.com$request_uri; 
} 

server { 
listen 80 default_server; 
server_name mrmerch.com; 
server_tokens off; 

access_log /var/log/nginx/mrmerch.access_log; 
error_log /var/log/nginx/mrmerch.error_log; 

root /home/paul/www/mistermerch.com/; 
try_files $uri $uri/ /index.php$is_args$args; 

gzip on; 
gzip_comp_level 6; 
gzip_vary on; 
gzip_min_length 1000; 
gzip_proxied any; 
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
gzip_buffers 16 8k; 
gzip_disable "MSIE [1-6]."; 

location = /favicon.ico { 
      log_not_found off; 
      access_log off; 
    } 

    location = /robots.txt { 
      allow all; 
      log_not_found off; 
      access_log off; 
    } 

location /artwork { 
    alias /home/mistermerch/www/; 
} 

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    #fastcgi_param SCRIPT_FILENAME /home/paul/www/mistermerch.com$fastcgi_script_name; 
    include fastcgi_params; 
} 

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { 
      expires max; 
      log_not_found off; 
    } 


    location ~* ^/Terms/ { 
    } 



} 

答えて

2

あなたは内部URIを書き換えるために大文字小文字を区別しない正規表現の場所を使用することができます。

location ~* ^/terms { 
    rewrite^/static/terms.html last; 
} 
この場合

/terms/terms//TeRmS、および/tErMs/など、すべての場所に書き換えされていますoutside正規表現の位置が一致しています。

あなたはまた、正規表現の場所に一致する宛先URIを使用したい場合には、完全一致の場所でそれを抽出することができます。

location ~* ^/terms { 
    rewrite^/terms/index.html last; 
} 
location = /terms/index.html { 
} 

は詳細についてはthis documentを参照してください。

関連する問題