I have installed Drupal 8 on Windows 10 via composer into a directory called fooproject under the htdocs directory.
Scenario 1:
I can access the site using localhost/fooproject/web. When I click the Log in button everything works as expected--generated URL is http://localhost/fooproject/web/user/login. However when I click the logout button, the generated url is localhost/logout and fails with URL was not found. I can logout if I enter localhost/fooproject/web/user/logout.
Scenario 2:
added entry to C:\windows\system32\drivers\etc
127.0.0.1 loc.fooproject.com
added the following to \xampp\apache\conf\extra\httpd-vhosts.conf
DocumentRoot "d:/xampp/htdocs/fooproject/web"
ServerName loc.fooproject.com
ServerAlias loc.fooproject.com.*.xip.io
Entering loc.fooproject.com displays the home page. However, now when I click on Log in, the generated URL is loc.fooproject.com/fooproject/web/user/login which fails. I can log in if I enter
loc.fooproject.com/user/login. After that, when I then click on the Log out button, the log out is successful.
Comments
Update the login logout link
Hi,
Please follow the below steps for update your login, logout link:
step 1:
Go to your theme folder and open the your_theme_name.theme file
Put this code in bottom of the page:
Make sure change your_theme_name on above mention
Step 2:
Go to your template twig file where login and logout link mention
And update the path
Login : {{base_url}}/user/login
logout : {{base_url}}/user/logout
It works all the place, no need to change every time.
Thanks
Dibyajyoti
Where is twig template file for login and logout links
Thank you for your reply. I completed step 1, but am having trouble trying to figure out where the twig template file for login and logout links is. I am using Bartik. Any suggestions?
TWIG debug mode
You may want to enable debugging for TWIG. https://www.drupal.org/docs/8/theming/twig/debugging-twig-templates
twig debug
I have enabled twig debug and get the following:
menu.html.twig has the following:
I do not know where to find where item.url is set up.
Put Condition
Hi,
Put condition :
Close, but
I appreciate you taking the time to reply to my request.
Your fix works for the login and logout, but I just noticed that "My Account" also references the wrong base_url. It seems odd that if Composer based installation of Drupal is going to be the new thing that there would be any need to change any twig files to address the move of the Drupal code to the web subdirectory.
Your Post
I agree and would also appreciate the solution