如何在apache中使用mod_rewrite作为其他应用程序

我对apache不是很有经验,但是我已经成功地在我的testing框上运行了以下几个月的设置:

me@mydev:/etc/apache2/sites-enabled$ vim 000-default.conf <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

所以基本上,任何时候我在/ var / www / html下创build一个新的文件夹,它都可以在我的浏览器中使用。 但是现在我想尝试做下面的事情:

我创build了一个新的应用程序,具有以下结构:

 /var/www/html/testrestapp/src/public/index.php 

它的工作原理,但我必须导航到:

 http://localhost/testrestapp/src/public/index.php/hello/sometestname 

然后应用程序返回“sometestname”

但我想知道如何configurationApache,以便我可以这样导航:

 http://localhost/testrestapp/hello/sometestname 

并得到相同的结果。

这是我如何修改我的000-default.conf文件(这是启用站点的文件夹中的唯一文件,btw):

 <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory "/var/www/html/testrestapp/"> RewriteEngine on RewriteBase /testrestapp/ RewriteRule ^src/public/index.php/hello$ hello/ [R] </Directory> </VirtualHost> 

但这不适合我 仍然得到一个404.任何build议,将不胜感激。 Apache版本是ubuntu上的Apache 2.4.12

谢谢。