# Slim works different if running apache or php built-in server

**URL:** <https://discourse.slimframework.com/t/slim-works-different-if-running-apache-or-php-built-in-server/1927>\
**Category:** Questions\
**Created:** [October 25, 2017, 5:01pm UTC](https://discourse.slimframework.com/t/slim-works-different-if-running-apache-or-php-built-in-server/1927 "2017-10-25T17:01:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pato.llaguno](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pato.llaguno](https://discourse.slimframework.com/u/pato.llaguno)\
**Post date:** [October 25, 2017, 5:01pm UTC](https://discourse.slimframework.com/t/slim-works-different-if-running-apache-or-php-built-in-server/1927/1 "2017-10-25T17:01:50Z")

</div>

I have been having some issues, i am using [This](https://github.com/pabloroca/slim3-simple-rest-skeleton) oauth library and at first I thought it had an error on it since i could get my tokens correctly but when consuming the tokens i got a 401 error, after some experimentation i found out that it has something to do with apache. If I start the php server from a command line it does work correctly, so now I am in a point where I have no idea what can apache be doing to make the scripts malfunction.

I have XAMPP installed on a windows machine. (Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.9)

I have the virtualhost configured in apache, like this.

> \<VirtualHost \*:80\>  
> DocumentRoot “C:/xampp/htdocs/slim3-simple-rest-skeleton-master/public”  
> ServerName TestSite

and my etc hosts file added the line

> 127.0.0.1 TestSite

with that configuration i am able to make a request to [http://testsite/oauth/token](http://testsite/oauth/token) and get my access token, so here everything works just fine.

but when i go to [http://testsite/books](http://testsite/books) i get a blank page with 401 unauthorized header.

in the other hand, if i go to my folder `slim3-simple-rest-skeleton-master` and run this

> php -S 0.0.0.0:8888 -t public/

i can get my token at [http://localhost:8888/oauth/token](http://localhost:8888/oauth/token) just as before, and when i do a get to [http://localhost:8888/books](http://localhost:8888/books) it works correctly.

i had to comment out

> if (PHP\_SAPI === ‘cli-server’ && $\_SERVER[‘SCRIPT\_FILENAME’] !== **FILE** ) {  
> return false;  
> }

in the app.php for this to work on php built-in server

---

<div class="post-metadata">

**Author:** ![geggleto](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/geggleto/32/11_2.png) [@geggleto](https://discourse.slimframework.com/u/geggleto)\
**Post date:** [October 25, 2017, 10:17pm UTC](https://discourse.slimframework.com/t/slim-works-different-if-running-apache-or-php-built-in-server/1927/2 "2017-10-25T22:17:56Z")

</div>

Haha yes, yes it does.

The built-in webserver does some weird stuff that they just don’t care enough about to fix.

---

<div class="post-metadata">

**Author:** ![pato.llaguno](https://avatars.discourse-cdn.com/v4/letter/p/90db22/32.png) [@pato.llaguno](https://discourse.slimframework.com/u/pato.llaguno)\
**Post date:** [October 26, 2017, 3:42am UTC](https://discourse.slimframework.com/t/slim-works-different-if-running-apache-or-php-built-in-server/1927/3 "2017-10-26T03:42:22Z")

</div>

but here is the other way around, the app works well under php built-in but not in apache
