简体   繁体   中英

Symfony Twig template form redirecting broken

I've moved my public directory into public_html , while dependency and vendor are accessible in public_html/core directory. I edited index.php located in public_html/forum and changed Env and vendor path to the correct path. So, no problem here. The problem comes at form redirecting in twig template. it redirects to localhost/login but it needs to be redirected to localhost/forum/login . Im using in twig the following attribute {{form_start(formLogin, {'action': absolute_url('/login'), 'method': 'POST'} ) }} tried everything and don't work :/. Is this a bug ?

Symfony 4.1 version i'm using.

It seems you are using absolute_url in a wrong way. Look at the document for reference.

If you are on this URL: http://example.com/products/hover-board

{{ absolute_url('/human.txt') }}
{# http://example.com/human.txt #}

{{ absolute_url('products_icon.png') }}
{# http://example.com/products/products_icon.png #}

If you remove the slash, it should work properly

I fixed temporary the problem by placing index.php in the root directory of public_html in my webhost. Added the .htaccess in the public_html as well and now it works good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM