apache2 RewriteEngine subfolder configuration is not wroking as expected. I am not sure how to correct it

67 Views Asked by At

The rewrite engine appears to be "functioning" but not as expected.

Here is the dir tree of my public_html folder (serving using apache2 in my userdir)

┌─[admini@linuxbox][~/public_html]
│ [13:16:45   Sat Jun 20]
└─> tree -L 2
.
├── index.php
└── me
    ├── app.log
    ├── app.txt
    ├── composer.json
    ├── composer.lock
    ├── index.php
    └── vendor

and my .htaccess file is

 RewriteEngine On
 RewriteBase /~admini/         

 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [QSA,L]

when I navigate to

http://10.0.0.30/~admini/me/name/foobar

My browser returns and renders the file contents of

http://10.0.0.30/~admini/index.php 

masked with

http://10.0.0.30/~admini/me/name/foobar

So it appears the rewrite engine is doing some work, but not as expected.

The expected (desired) behavior is

when I navigate to

http://10.0.0.30/~admini/me/name/foobar

My browser returns and renders the file contents of

http://10.0.0.30/~admini/me/index.php 

Please note / other context:

Other Note: I have tried basic troubleshooting by changing paths to the correct directories with negative results.

Context Note: I am using http://www.slimframework.com/ to attempt to render the default example in a sub directory in my userdir

<?php
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
});
$app->run();

the above file is located in

┌─[admini@linuxbox][~/public_html]
│ [13:16:45   Sat Jun 20]
└─> tree -L 2
.
├── index.php
└── me
    ├── app.log
    ├── app.txt
    ├── composer.json
    ├── composer.lock
****├── index.php     ****
    └── vendor
1

There are 1 best solutions below

0
On

Resolved the issue by using this as my .htaccess file

RewriteEngine On    

RewriteBase /~admini/me/    

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]