# Authentication plugin gives me exception in local environment in cakephp 4.4

**URL:** https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501
**Category:** Need Help
**Created:** [September 7, 2023, 3:57pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501 "2023-09-07T15:57:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)
#### Post date: [September 7, 2023, 3:57pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/1 "2023-09-07T15:57:17Z")

</div>

When I try to login to the site the Authentication plugin gives me this exception: Login URL `/cif/` did not match `/cif`., this is with wampserver in windows 10, the url is [http://localhost/cif/](http://localhost/cif/), the route in routes.php is established with this code:

```auto
$builder->connect('/', ['controller' => 'Users', 'action' => 'login']);

```

How can I solve this issue?

---

<div class="post-metadata">

### Author: ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)
#### Post date: [September 8, 2023, 8:29pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/2 "2023-09-08T20:29:50Z")

</div>

Can you please help me with this? I don’t know how to solve this issue.

---

<div class="post-metadata">

### Author: ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)
#### Post date: [September 9, 2023, 3:23pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/3 "2023-09-09T15:23:11Z")

</div>

Re-asking for support for already posted questions won’t give you faster support.

Please remember, this is a support forum purely driven by volunteers. If you want to have faster/better support please contact [CakeDC](https://www.cakedc.com/)

Besides the fact that your given information doesn’t provide the root cause of your problem.

In a default CakePHP installation where the `webroot` is mapped to the docroot your `/` route should be connected to [http://localhost](http://localhost), not [http://localhost/cif/](http://localhost/cif/)

---

<div class="post-metadata">

### Author: ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)
#### Post date: [September 9, 2023, 6:47pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/4 "2023-09-09T18:47:32Z")

</div>

I’m sorry to be so insistent but I need to solve this issue as son as possible.  
Answering to your comment that the site should point to [http://localhost](http://localhost) and not to [http://localhost/cif/](http://localhost/cif/) in [http://localhost](http://localhost) is the index page of wampserver and when you créate the cakephp project with composer you put the directory where the cakephp files will be downloaded and in my case that directory is cif.  
I need to test this site in local and then upload it to a server, so I will appreciate all the help you can give me and won’t annoy you any more

---

<div class="post-metadata">

### Author: ![KevinPfeifer](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kevinpfeifer/32/3365_2.png) [@KevinPfeifer](https://discourse.cakephp.org/u/KevinPfeifer)
#### Post date: [September 9, 2023, 7:50pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/5 "2023-09-09T19:50:26Z")

</div>

> [@mdeanquin](#):
>
> won’t annoy you any more

Its not about annoying me or any one else in here. Its more about the fact that you need to learn how to google your problems instead of posting your problems in support forums so other people are solving the problems for you. Thats a very important thing to learn as a developer in general since no one can know everything (and thats fine).

So here is what i did:  
All I had to google was `wampserver change docroot`  
and the first link is [Change the www root directory on WampServer – Rui Miguel Feio](https://ruifeio.com/2011/01/30/change-the-www-root-directory-on-wampserver/)  
or [How To Change The WWW Root Directory On WampServer | Tutorials24x7](https://apache.tutorials24x7.com/blog/how-to-change-the-www-root-directory-on-wampserver)

CakePHP expects you to configure your webserver correctly - meaning (as I explained above) that the docroot of your application is set to the `webroot` folder of cakephp. This is also mentioned in the [documentation](https://book.cakephp.org/4/en/installation.html#production).

In your case you are installing cakephp via `composer create-project cakephp/app cif` inside the default docroot of Wampserver.

This of course leads to a URL of [http://localhost/cif](http://localhost/cif) because wampserver just lists whatever is listed in the given folder and cakephp’s root directory has a [index.php](https://github.com/cakephp/app/blob/4.x/index.php) which is one of the default files to display for a webserver.

But as you can see in the linked index.php file all it does is load the `webroot/index.php`.

So you know have 2 options:

- adjust your webserver to point to the correct folder so you have clean URL’s with the `cif` part
- adjust cakephp’s config so it knows it lives inside a subfolder and not in the docroot (which comes with its own sort of problems)

---

<div class="post-metadata">

### Author: ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)
#### Post date: [September 9, 2023, 9:24pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/6 "2023-09-09T21:24:54Z")

</div>

Thank you @KevinPfeifer it didn’t occur to me that the problem was on apache and not in cakephp

---

<div class="post-metadata">

### Author: ![mdeanquin](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/mdeanquin/32/1802_2.png) [@mdeanquin](https://discourse.cakephp.org/u/mdeanquin)
#### Post date: [September 10, 2023, 3:59pm UTC](https://discourse.cakephp.org/t/authentication-plugin-gives-me-exception-in-local-environment-in-cakephp-4-4/11501/7 "2023-09-10T15:59:54Z")

</div>

I solved it creating a virtual host with wampserver, thank you very much for your help
