我有一个简单的根目录,如果没有/ 因此,此http://example.com/app解决了错误:
ResourceNotFoundException NotFoundHttpException HTTP 404找不到 找到“ GET / app”的路线
但是如果我执行http://example.com/app / (我在网址末尾添加了“ /”),路由器就可以正常工作。
路由器:
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
/**
* @Route("/", name="index")
*/
public function index()
{
return $this->render('index/index.html.twig', [
'controller_name' => 'IndexController',
]);
}
}
我想念什么?问题出在nginx配置上?
server {
listen 80;
server_name ~^(?<folder>[^.]*).magana.dev.example.fr;
charset utf-8;
index index.php index.html index.htm;
set $symfonyRoot /var/www/projects/dev/magana/$folder/htdocs/app/public;
set $symfonyScript index.php;
root /var/www/projects/dev/magana/$folder/htdocs;
access_log /var/www/projects/dev/magana/$folder/access.log;
error_log /var/www/projects/dev/commons/logs/magana_error.log;
client_max_body_size 200M;
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|js|css)$ {
access_log off;
log_not_found off;
expires 30d;
add_header Pragma "public";
}
location /app {
root $symfonyRoot;
rewrite ^/app/(.*)$ /$1 break;
try_files $uri @symfonyFront;
}
location @symfonyFront {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $symfonyRoot/$symfonyScript;
fastcgi_param SCRIPT_NAME /app/$symfonyScript;
fastcgi_param REQUEST_URI /app$uri?$args;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APPLICATION_ENV magana;
include fastcgi_params;
fastcgi_read_timeout 600;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SERVER_NAME $folder.magana.dev.example.fr;
}
location ~ /\.ht {
deny all;
}
}
答案 0 :(得分:1)
如果划分不同的位置块,则更容易理解。
add_filter( 'woocommerce_checkout_fields' , 'disabling' );
function disabling($fields){
$product_id = 989; //product id which would trigger
$in_cart = false;
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_in_cart = $cart_item['product_id'];
if ( $product_in_cart === $product_id ) $in_cart = true; // checks if the product is in cart
}
if ( $in_cart ){
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_phone']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
return $fields;
}
else {
return $fields;
}
}
希望我能帮上忙。