In my development environment, I use the web built-in web server of php5.4 but it seems that .htaccess doesn't work correctly. I can't found the doc of that server. Can someone tell me if it is possible to use htaccess and mod_rewrite like apache?
Thank you very much
As in my comment mentioned, the current directory is by default your webroot. Also this webserver doesn't support .htaccess
.
You'll find a good explanation about your issues here.
Get the Server Running
By default, the current directory is your webroot and you can now request whatever files are here, and run PHP in the usual way
or
Routing Requests Like Apache Rewrite
One immediate feature that I was looking for was the ability to redirect all incoming requests to index.php, which I usually do with an .htaccess file. This webserver doesn't support those (although my good friend Josh has created something pretty close) but it does support a routing file.
I am not a fan doing of this, but I have seen this done in the wild, by the software Magento:
/**
* Parse .htaccess file and apply php settings to shell script
*
*/
protected function _applyPhpVariables()
{
$htaccess = $this->_getRootPath() . '.htaccess';
if (file_exists($htaccess)) {
// parse htaccess file
$data = file_get_contents($htaccess);
$matches = array();
preg_match_all('#^\s+?php_value\s+([a-z_]+)\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER);
if ($matches) {
foreach ($matches as $match) {
@ini_set($match[1], str_replace("", '', $match[2]));
}
}
preg_match_all('#^\s+?php_flag\s+([a-z_]+)\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER);
if ($matches) {
foreach ($matches as $match) {
@ini_set($match[1], str_replace("", '', $match[2]));
}
}
}
}
It's meant for applying PHP settings from .htaccess
to PHP CLI scripts, but I imagine it should work well for PHP's built-in web server as well.