# \[Solved\] Apache Alias and Slim 4

**URL:** <https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325>\
**Category:** Questions\
**Created:** [August 8, 2019, 11:25am UTC](https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325 "2019-08-08T11:25:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@Quentin](https://discourse.slimframework.com/u/Quentin)\
**Post date:** [August 8, 2019, 11:25am UTC](https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325/1 "2019-08-08T11:25:06Z")

</div>

Hello,  
I would like to launch a new project with Slim 4.  
But when I want to create an alias with a RewriteBase in the .htaccess as I did in Slim 3, I get an error “NOT FOUND”, the subject has already been treated in another post. However the solution provided (RewriteBase does not work for me.)  
Here is an example of configuration on a test machine:  
VirtualHost :

> ```
> ServerAdmin webmaster@localhost
> DocumentRoot /var/www/html/
> Alias "/api" "/var/www/html/wbs/slim4/public"
> <Directory "/api">
> Options Indexes FollowSymLinks MultiViews
> AllowOverride All
> Order allow,deny
> Allow from all
> </Directory>
> 
> ```

.htaccess :

> RewriteEngine On  
> RewriteBase /api  
> RewriteCond %{REQUEST\_FILENAME} !-f  
> RewriteRule ^ index.php [QSA,L]

Thank you in advance for your ideas or solutions.

---

<div class="post-metadata">

**Author:** ![architshin](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@architshin](https://discourse.slimframework.com/u/architshin)\
**Post date:** [August 9, 2019, 5:52pm UTC](https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325/2 "2019-08-09T17:52:44Z")

</div>

Hello.  
The same problem has been discussed at the following thread.  
[https://discourse.slimframework.com/t/slim-4-httpnotfoundexception/3273](https://discourse.slimframework.com/t/slim-4-httpnotfoundexception/3273)

---

<div class="post-metadata">

**Author:** ![Quentin](https://avatars.discourse-cdn.com/v4/letter/q/e47c2d/32.png) [@Quentin](https://discourse.slimframework.com/u/Quentin)\
**Post date:** [August 27, 2019, 7:51am UTC](https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325/3 "2019-08-27T07:51:31Z")

</div>

Hello,  
Thank you for your link. I had seen this topic, but the solution was not at the top.  
By dint of research I found the solution. You have to “just” use the function $ app-\> setBasePath  
And inform the path in the rewriteurl  
ex:  
Add after $app-\>setBasePath("/ **youralias**"); After AppFactory::create();

on the .htaccess verifiy this line :  
RewriteRule ^ / **youralias** /index.php [QSA,L]

source:

> <https://github.com/slimphp/Slim/issues/2512>

---

<div class="post-metadata">

**Author:** ![architshin](https://avatars.discourse-cdn.com/v4/letter/a/779978/32.png) [@architshin](https://discourse.slimframework.com/u/architshin)\
**Post date:** [August 27, 2019, 8:24am UTC](https://discourse.slimframework.com/t/solved-apache-alias-and-slim-4/3325/4 "2019-08-27T08:24:15Z")

</div>

@Quentin  
Thanks! This is great information.
