0

I installed a Slim framework to create a API and located this under

 /opt/modul/www/api
    index.php
    slim/

so the index.php is my main API file. And I want to access this in the browser under the URL localhost/mo/api

to enable the rewrite mode I created a /opt/modul/www/api/.httacces file

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} !-f 
 RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
</IfModule>

and put to http.conf

Alias /mo /opt/modul/www

<Directory /opt/modul/www>
        DirectoryIndex index.html index.php
        Order allow,deny
        Allow from all
        AllowOverride All
</Directory>

but if I access the URL localhost/mo/api in the browser I see in error.log

File does not exist: /var/www/html/opt

why it still looks in /var/www/html? I know, this i a document_root, but is the alias not overwrite it?

user1908375
  • 133
  • 4

1 Answers1

0

To solve this I point the RewriteRule to the absolute location of index.php, based on the ALIAS.

RewriteRule ^(.*)$ /mo/api/index.php [QSA,L]
Froggiz
  • 3,043
  • 1
  • 19
  • 30
user1908375
  • 133
  • 4