0

I have a SLIM project I have set up for a RESTful webs service. My project structure is as below:

-MyProject
   -app
   -logs
   -public
     -index.php
     -.htaccess
   -vendor
   -composer.json
   -composer.lock

So right now to access my routes I would need something like https://myuri/MyProject/public/endpoint

I want to remove the public directory from the url so my request looks more like https://myuri/MyProject/endpoint

I have tried adding an .htaccess to my root directory:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/
RewriteRule ^(.*)$ /public/$1 [R=301,L]

I just get page not found. What is the best way to remove the public directory from the url?

bos570
  • 1,505
  • 2
  • 23
  • 45
  • take index.php and .htaccess file outside of public folder and remove public from `RewriteRule ^(.*)$ /public/$1 [R=301,L]` so it should be `RewriteRule ^(.*)$ /$1 [R=301,L]` – Pankaj Makwana Jun 19 '17 at 20:09
  • I tried doing that but I keep getting redirected to `/MyProject/public/` now. – bos570 Jun 19 '17 at 20:22
  • 1
    check this post this will help you. https://stackoverflow.com/questions/41505870/slim-framework-public-folder-redirect OR You can try this `RewriteEngine On` `RewriteCond %{REQUEST_FILENAME} !-f` `RewriteCond %{REQUEST_FILENAME} !-d` `RewriteRule ^ index.php [QSA,L]` – Pankaj Makwana Jun 19 '17 at 20:29

0 Answers0