У меня возникли проблемы с перезаписью URL-адресов. Когда я нажимаю ссылку в моем бэкенде Magento, он полностью портит URL.
Начнем с этой ссылки:
http://icanttellmydomain.nl/index.php/paneel/dashboard/index/key/26f665360ac9f2e3e9b5c69b09 7fcb6b /
Но нас перенаправляют сюда:
Он продолжает повторять index.php и путь URL-адреса, зацикливаясь, пока не выдаст мне внутреннюю ошибку 500 или «Страница не перенаправляется должным образом».
Я почти уверен, что это связано с моей конфигурацией виртуального хоста. Я пробовал комментировать:
#Forward paths like /js/index.php/x.js to relevant handler
# location ~ .php/ {
# rewrite ^(.*.php)/ $1 last;
# }
но это не помогло.
Мой Vhost:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
listen 443 default ssl;
root /usr/share/nginx/www/xxxxxxxx/public/;
index index.html index.htm;
# Make site accessible from http://<serverip/domain>/
server_name xxx.xxx.xxx.xxx;
error_log /var/log/nginx/error.log; #warn; #op warn niveau word er logged
#access_log off; #Disabled voor I/O besparing
access_log /var/log/nginx/access.log;
location / {
index index.html index.php;
#autoindex on;
## If missing pass the URI to Magento's front handler
try_files $uri $uri/ @handler;
expires max; ##
}
## These locations need to be denied
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
## Disable .htaccess and other hidden files
location /. {
access_log off;
log_not_found off;
return 404;
deny all;
}
## Magento uses a common front handler
location @handler {
rewrite / /index.php;
}
#Forward paths like /js/index.php/x.js to relevant handler
# location ~ .php/ {
# rewrite ^(.*.php)/ $1 last;
# }
##Rewrite for versioned CSS+JS via filemtime(file modification time)
location ~* ^.+\.(css|js)$ {
rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
expires 31536000s;
access_log off;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public";
}
## php-fpm parsing
location ~ \.php.*$ {
## Catch 404s that try_files miss
if (!-e $request_filename) { rewrite / /index.php last; }
## Disable cache for php files
expires off;
## php-fpm configuration
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
## Store code is located at Administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
## Tweak fastcgi buffers, just in case.
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
Спасибо за прочтение! Я новичок во всем этом, поэтому примите это во внимание в своих ответах, пожалуйста.
Пожалуйста, попробуйте эти решения
Отключить
слушать [::]: 80 default_server ipv6only = on; ## слушать ipv6
Изменить
index index.html index.htm; === индекс index.php;
Изменить
местоположение ~ .php. * $ {=== местоположение ~ .php $ {
Я не понимаю эту часть, поэтому попробуйте отключить ее
Переписать для версионного CSS + JS через filemtime (время модификации файла), расположение ~ * ^. +. (Css | js) $ {rewrite ^ (. +). (\ D +). (Css | js) $ 1. $ 3 last; истекает 31536000 с; access_log off; log_not_found off; add_header Pragma public; add_header Cache-Control "max-age = 31536000, общедоступный"; }
Очистите кеш и отключите кеш, используйте частный браузер для тестирования
Публикация моей рабочей конфигурации nginx php, найденной здесь: http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento
location /. { ## Disable .htaccess and other hidden files
return 404;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param HTTPS on;
fastcgi_param HTTPS $https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE store_code; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}