mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 20:12:14 +00:00
Added .htaccess example to documentation (issue #232)
This commit is contained in:
@@ -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.
|
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
|
### 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.
|
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.
|
||||||
|
|||||||
@@ -77,10 +77,10 @@ class RouterRouteTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
public function testPathParamRegex()
|
public function testPathParamRegex()
|
||||||
{
|
{
|
||||||
TestRouter::get('/test/path/{myParam}', 'DummyController@param', ['where' => ['myParam' => '([0-9]+)']]);
|
TestRouter::get('/{lang}/productscategories/{name}', 'DummyController@param', ['where' => ['lang' => '[a-z]+', 'name' => '[A-Za-z0-9\-]+']]);
|
||||||
$response = TestRouter::debugOutput('/test/path/123123', 'get');
|
$response = TestRouter::debugOutput('/it/productscategories/system', 'get');
|
||||||
|
|
||||||
$this->assertEquals('123123', $response);
|
$this->assertEquals('it, system', $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDomainAllowedRoute()
|
public function testDomainAllowedRoute()
|
||||||
|
|||||||
Reference in New Issue
Block a user