0

I'm having trouble getting Slim to run in my user account on the university's web server. I'm pretty sure I'm just missing a step in my .htaccess file.

I have placed my Slim application in /home/smithj/public_html/CS371/MySlimApp

My .htaccess file looks like this:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /~smithj/CS371/MySlimApp/public/index.php [L]

Requests to the app are correctly being redirected to index.php; but, only the root route works. I added a default handler and I see that the path given to the router begins with the root of my user account instead of the root of the app. Specifically, when trying to access http://www.mega.edu/~smithj/CS371/MySlimApp/public/testMe, $request->getURI()->getPath() is /~smithj/CS371/MySlimApp/public/testMe instead of just /testMe as expected.

What else do I need to do to correctly configure the root of the app?

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Zack
  • 6,232
  • 8
  • 38
  • 68
  • Why `/~smithj` and not `/home/smithj` or just nothing? – Álvaro González May 31 '17 at 16:48
  • The web server is configured so that our personal web pages go in `/home/smithj/public_html`. For example, the url `http://www.mega.edu/~smithj/cv.html` returns the file `/home/smithj/public_html/cv.html`. I put `/~smithj/` in the `.htaccess` file instead of `/home/smithj/public_html` because that's what almost worked. Using `/home/smithj/public_html/CS371/MySlimApp/public/index.php` caused a redirect to the main university web page for some reason. – Zack May 31 '17 at 16:52
  • A `RewriteRule` redirection can be either external (in which case you provide a full URL, including protocol and host name) or internal (in which case you provide a filesystem location). I don't think your `.htaccess` needs to mention `~smithj` at all. – Álvaro González May 31 '17 at 16:56
  • What would a rule look like that doesn't mention `~smithj`? – Zack Jun 01 '17 at 11:48
  • Out of curiosity, did you try the default template, `RewriteRule ^ index.php [L]`, with the `.htaccess` file located in the `public` folder? – Álvaro González Jun 01 '17 at 11:57
  • When I make that change, the .htaccess file doesn't seem to have any effect (but, I don't understand why). – Zack Jun 01 '17 at 12:16
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/145632/discussion-between-zack-and-alvaro-gonzalez). – Zack Jun 01 '17 at 12:17

0 Answers0