We are developing a new Magento 2 website for a client who is currently using a Magento 1 website. All their category URLs end with a forward slash ("/"), but this doesn't work in Magento 2.
In Magento 2, when I set a forward slash as the Category URL Suffix, all category pages show a 404 Not Found page. Using something like "a/" doesn't work either. I've also tried to reindex the indexes manually, but that doesn't do the trick.
Does anybody has a Magento 2 website where this works as expected?
Edit: added nginx config
For nginx we're using a slightly adjusted version of the sample config. When the suffix is set to a forward slash, Magento shows it's own 404 page so I guess the problem is within Magento – not in the nginx config. But maybe I'm wrong, so here's the config:
server {
*listen & server name*
# Set Mage root
set $mage_root /var/www/domains/*domain*;
root $mage_root/pub;
# Some general settings applying to all locations
index index.html index.php; ## Allow a static html file to be shown first
autoindex off;
charset off;
add_header 'X-Content-Type-Options' 'nosniff';
add_header 'X-XSS-Protection' '1; mode=block';
location /setup {
*setup folder rules*
}
location /update {
*update folder rules*
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location /pub {
location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) { deny all; }
alias $mage_root/pub;
add_header X-Frame-Options "SAMEORIGIN";
}
location /static/ {
if ($mage_mode = "production") {
expires max;
}
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
add_header X-Frame-Options "SAMEORIGIN";
expires off;
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
}
if (!-f $request_filename) {
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
}
add_header X-Frame-Options "SAMEORIGIN";
}
location /media/ {
try_files $uri $uri/ /get.php?$args;
location ~ ^/media/theme_customization/.*\.xml { deny all; }
location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
try_files $uri $uri/ /get.php?$args;
}
location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
add_header Cache-Control "no-store";
add_header X-Frame-Options "SAMEORIGIN";
expires off;
try_files $uri $uri/ /get.php?$args;
}
add_header X-Frame-Options "SAMEORIGIN";
}
## These locations should be protected
location /media/customer/ { deny all; }
location /media/downloadable/ { deny all; }
location /media/import/ { deny all; }
location ~ cron\.php { deny all; }
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location ~ (index|get|static|report|404|503)\.php$ { ## Execute PHP scripts
try_files $uri =404;
expires off; ## Do not cache dynamic content
fastcgi_pass php7-0;
proxy_read_timeout 600s;
proxy_connect_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_read_timeout 600s;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600";
fastcgi_param MAGE_MODE $mage_mode;
fastcgi_param MAGE_RUN_CODE $mage_code;
fastcgi_param MAGE_RUN_TYPE $mage_type;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
location ~* ^.+\.php$ {
return 404;
}
}
Edit2: added setting examples
Platform: Magento 1 Magento 2
-----------------------
Category suffix set to: Gives:
"" domain.tld/category Works Works
".html" domain.tld/category.html Works Works
"/" domain.tld/category/ Works Doesn't work (404 page)
Best Answer
I had same issue. I made a patch that fixes it for me and illustrates problem.
https://github.com/magento/magento2/pull/7041/commits/1f9a6ec7e106b9778e45356511d4b95defa386c5
Hopefully get's merged one day