Reputation: 659
Ok, I am not sure if this is me but I have just come across the Slim framework for PHP which looks very simple and easy to round about better apps with. I am sure its my .htaccess file and I am not sure what the hell I am doing wrong.
So this works with Slim :
http://testvm/index.php/hello/4412
But this
http://testvm/hello/4412
Gives me a not found error, from Apache,
This
http://testvm/
returns a 404 error from Slim (or at lest I think its a 404 from slim).
This might be a better question for Server Fault but it could be the way I have set up Slim, I am very new to this and to PHP Composer, which I used to install Slim.
This is my index.php file
<!doctype html><html>
<head><meta charset="utf-8"><title>Untitled Document</title></head> <body>
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->run();
?>
</body></html>
This is my current .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
#RewriteRule ^$ /testvm/index.php/ [L]
#RewriteRule (.*) /testvm/index.php/$ [L]
If I uncomment the bottom two rules I get a server 500 error?
I have already tried
RewriteEngine On
RewriteBase /my_app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
This makes "/testvm/index.php/hello/XXXX" work but I want it to work without any index.php file within the URL? I am sure this has to be something to do with my .htaccess files.
Now I am running this within a VM (Virtual Machine) which is Ubuntu 13.04, which has been fully updated just not to 13.10 let. I have checked and the rewrite.load is listed within the modes-enable folder in my apache build on this VM.
So what I am doing wrong?
All help some welcome. :)
Glenn.
Upvotes: 2
Views: 7146
Reputation: 659
I have markered your answer has right because you gave me lots of help and I have got it to work, with the follow code,
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [QSA]
so now if I go to testvm/ i get a slim 404 error and when loading testvm/hello/TESTNAMEEXAMPLE it loads.
Hope my code above will help someone else about.
Glenn.
Upvotes: 0
Reputation: 786091
Can you try this rule in DOCUMENT_ROOT/testvm/.htaccess
file:
RewriteEngine On
RewriteBase /
RewriteRule ^$ /testvm/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^testvm/((?!index\.php/).+)$ /testvm/index.php/$1 [L,NC]
Upvotes: 1