diff --git a/README.md b/README.md index 0aeb668..0b90709 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,20 @@ location / { Nothing special is required for Apache to work. We've include the `.htaccess` file in the `public` folder. If rewriting is not working for you, please check that the `mod_rewrite` module (htaccess support) is enabled in the Apache configuration. +#### .htaccess example + +Below is an example of an working `.htaccess` file used by simple-php-router. + +Simply create a new `.htaccess` file in your projects `public` directory and paste the contents below in your newly created file. This will redirect all requests to your `index.php` file (see Configuration section below). + +``` +RewriteEngine on +RewriteCond %{SCRIPT_FILENAME} !-f +RewriteCond %{SCRIPT_FILENAME} !-d +RewriteCond %{SCRIPT_FILENAME} !-l +RewriteRule ^(.*)$ index.php/$1 +``` + ### Configuration Create a new file, name it `routes.php` and place it in your library folder. This will be the file where you define all the routes for your project. diff --git a/test/RouterRouteTest.php b/test/RouterRouteTest.php index ae045ee..d913248 100644 --- a/test/RouterRouteTest.php +++ b/test/RouterRouteTest.php @@ -77,10 +77,10 @@ class RouterRouteTest extends PHPUnit_Framework_TestCase public function testPathParamRegex() { - TestRouter::get('/test/path/{myParam}', 'DummyController@param', ['where' => ['myParam' => '([0-9]+)']]); - $response = TestRouter::debugOutput('/test/path/123123', 'get'); + TestRouter::get('/{lang}/productscategories/{name}', 'DummyController@param', ['where' => ['lang' => '[a-z]+', 'name' => '[A-Za-z0-9\-]+']]); + $response = TestRouter::debugOutput('/it/productscategories/system', 'get'); - $this->assertEquals('123123', $response); + $this->assertEquals('it, system', $response); } public function testDomainAllowedRoute()