AH HA! i found my answer here -> MAMP Silex htaccess.
I'm hoping this solution will help other people from going though my pain! :)
Question
I know there are SEVERAL similar questions already asked on this topic. I've looked at all of them and none of them have solved my issues. Here's what i have done so far:
.htaccess file:
Options -MultiViews
RewriteEngine On
## this was uncommented because silex is in a subdir
RewriteBase /~username/silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
/silex/web/index.php file:
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
echo "HELLO";
$app->get('/', function() {
return 'Hello!';
});
$app->run();
When I get to the silex/web/index.php here's what I get:
I've been working on this for about 2 days now and am starting to lose it. any help will be greatly appreciated. thanks.
Solution
AH HA! i found my answer here -> MAMP Silex htaccess.
I'm hoping this solution will help other people from going though my pain! :)
OTHER TIPS
In your .htaccess is missing the rewrite condition for the directory, try this:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /~username/silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>
or use
FallbackResource /~username/silex/web/index.php
if your Server is running Apache >= 2.2.16.
Expanding on the solution, you need to create an htaccess for the subdirectory containing Silex (and probably Symfony, etc) and tell Apache how to interpret routes. To paraphrase crzpata's Gist:
<IfModule mod_rewrite.c>
RewriteEngine on
#UNCOMMENT next line if silex app root is in a mamp subdirectory
#RewriteBase /your_mamp_htdocs_silex_app_root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ web/index.php [L]
</IfModule>
Then define your silex routes using that defined root:
$app->get('/directory_in_silex_root'...