我将 Silex“微框架”用于我的应用程序的路由目的。 我目前在研究如何使用 .htaccess 重写 url。
标准 Silex 网址:localhost/myapp/web/index.php/hello/name
我希望它看起来像:localhost/myapp/hello/name
使用以下 .htaccess 代码,我可以省略 /index.php/
部分。但我仍然必须使用 /web/
部分。
RewriteEngine On
RewriteCond %{THE_REQUEST} /myapp/web/index.php/
RewriteRule ^/myapp/web/index.php/(.*) /myapp/$1 [R=301,L]
RewriteCond %{REQUEST_URI} !/myapp/web/index.php/
RewriteRule ^(.*)$ /myapp/web/index.php/$1 [L]
有什么建议吗? 谢谢!
最佳答案
我现在遇到了同样的问题,解决方案是将 .htaccess 内容更改为:
FallbackResource /index.php
所以在你的情况下会是
FallbackResource /web/index.php
这对我有用,我希望有人会发现它有用。
关于php - Silex 路由 .htaccess webroot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15461091/