On a Zend Framework 2 based website (test environment on nginx and live environment on Apache) there is a category "courses" and its pages have URIs like this:
domain.tld/courses/123-Name of course that can contain ®, €, (, ), and other special chars
The courses names come from the database and are URL-encoded for the internal links:
domain.tld/courses/123-Name%20of%20course%20that%20can%20contain%20%C2%AE%2C%20%E2%82%AC%2C%20%C3%A4%2C%20(%2C%20)%2C%20and%20other%20special%20chars
It's working fine, but when I try to access a page using a special character without encoding a 404-error occures.
An example of website, that uses spacial characters is Wikipedia. You can use
http://en.wikipedia.org/wiki/Signal_(electrical_engineering)
or
http://en.wikipedia.org/wiki/Signal_%28electrical_engineering%29
and are always get the page you want.
Does someone know, how to achieve such behavior ("à la Wikipedia")? (Maybe with HTTP redirecting with a .htaccess
rule?)
UPDATE:
/etc/nginx/ax-common-vhost
server {
listen 80;
server_name
foo.loc
bar.loc
baz.loc
;
if ($host ~ ^(?<project>.+)\.(?<area>.+)\.loc$) {
set $folder "$area/$project";
}
access_log /var/log/nginx/$area/$project.access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_min_length 1000;
gzip_types text/plain text/xml application/xml;
client_max_body_size 25m;
root /var/www/$folder/public/;
try_files $uri $uri/ /index.php?$args;
index index.html index.php;
location / {
index index.html index.php;
sendfile off;
}
location ~ (\.inc\.php|\.tpl|\.sql|\.tpl\.php|\.db)$ {
deny all;
}
location ~ \.htaccess {
deny all;
}
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
location ~ \.php$ {
fastcgi_cache off;
#fastcgi_pass 127.0.0.1:9001;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 6000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV development;
fastcgi_param HTTPS $https;
}
}