herrjeh42
herrjeh42

Reputation: 2793

Using Silex without a vhost and Apache

I am setting up my first Silex project using Fabien's skeleton on Github: https://github.com/fabpot/Silex-Skeleton

For some reason I can't create a vhost for this project, the silex project stays in a sub directory.

My directory structure looks like this:

/my/example.com/htdocs/myapp/
      ../src/app.php
      ../cache
      ../config
      ../templates
      ../vendor
      ../web/index.php 

I want to access my app through the URL : http://example.com/myapp/hello/Fabien/

I have created a .htaccess file in htdocs/myapp

<IfModule mod_rewrite.c>
   Options -MultiViews
   RewriteEngine On
   RewriteBase /myapp
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteRule ^ web/index.php [L]
</IfModule> 

Now I have urls like http://example.com/myapp/index.php/hello/Fabien/

How can I get rid of the index.php?

Upvotes: 1

Views: 1225

Answers (2)

gerkirill
gerkirill

Reputation: 11

FYI: you can run Silex with php built-in web server, w/o Apache at all. That's handy to quick-start hacking / prototyping in your local development environment. composer.json of Fabien's skeleton contains instructions to start local web server. You can do that by executing composer run in the project directory.

The limitation of this approach is that composer will stop the server in 300 seconds. To avoid that - you should execute following command directly: php -S localhost:8888 -t web web/index_dev.php. Hello page will be available at http://localhost:8888/hello/Fabien/.

Upvotes: 0

AdrienBrault
AdrienBrault

Reputation: 7745

You should change the RewriteBase directive to /myapp/web:

RewriteBase /myapp/web

Upvotes: 1

Related Questions