0

OK, I'm probably going to be told this has been answered, but none of the answers here have helped me.

What I need to do is have everything that is not an image, css, script serve up my index file that is in /public.

!!! THIS IS FOR LOCAL DEV ON MAC OS X !!!

SO:

localhost/~username/PROJECT_NAME/
localhost/~username/PROJECT_NAME/some_dir/
localhost/~username/PROJECT_NAME/some_dir/some_other_dir

All, should use /public/index.php

Images, stylesheets, scripts etc. are also within the /public dir at:

/public/images
/public/styles
/public/scripts

Nothing should 404... it should be sent through /public/index.php

I would have to back my code out for the next hour to list all of the combinations I've tried, but I'm sure this is probably pretty simple and I've just missed it somewhere.

EDIT!!!

As I suspected... this question was flagged as a possible duplicate right away. And believe me, I have combed over all answers and none of them have solved this.

Maybe it's my bad as this is local dev on Mac OS X. SO I have edited the other content to reflect. Possibly this makes a difference?

Tomas
  • 3,054
  • 5
  • 27
  • 39
  • Possible duplicate of [Redirect all to index.php htaccess](https://stackoverflow.com/questions/18406156/redirect-all-to-index-php-htaccess) – M. Eriksson Feb 07 '18 at 06:19
  • ^ The above answer redirects calls to files that doesn't actually exist to index.php. If a file _does_ exist, then it will be service up instead. – M. Eriksson Feb 07 '18 at 06:20
  • The answer in that question does NOT solve this issue at all as I have already tried it. – Tomas Feb 07 '18 at 06:30
  • So, what doesn't it solve? What happens if you remove the `RewriteCond %{REQUEST_FILENAME} !-d` line? Then it will only serve up existing files (not folders). – M. Eriksson Feb 07 '18 at 06:35
  • What doesn't work is anything really. Going to `/` while using `/public/index.php?path=$1` just shows a directory listing. And of course omitting the /public isn't right either. – Tomas Feb 07 '18 at 06:38
  • Is your document root one step above /public? In which folder is the htaccess file? – M. Eriksson Feb 07 '18 at 06:43
  • Yes, public is in the doc root... it is NOT the doc root. The htaccess file is in the root. – Tomas Feb 07 '18 at 07:28
  • So your web server is configured to use the `public` folder as document root (i.e. http://localhost points to the `public` folder?) but you have the `htaccess` one step above? `htaccess` needs to go in the document root. – M. Eriksson Feb 07 '18 at 07:33
  • No, it’s not setup that way at all. The real doc root on Mac OS X is /Users/[USERNAME]/Sites and you can then choose to use folders there as root for housing multiple websites which would be accessible at localhost/~[USERNAME]/Sites/project1 localhost/~[USERNAME]/Sites/project2 localhost/~[USERNAME]/Sites/project3 etc. – Tomas Feb 07 '18 at 12:16
  • So you're using Mac OSX defautl Apache server? You might want to include that in your question since most developers uses MAMP/Docker/Vagrant or similar for local development on OSX. – M. Eriksson Feb 07 '18 at 13:08
  • I’m pretty sure the htaccess rules don’t change because of this difference... the fact is the htaccess file follows rules based on its location in the project and based on your access point... this should not be all that hard and I wouldn’t need to ask, but I lost my htaccess file that was working some time ago. – Tomas Feb 07 '18 at 14:07

0 Answers0