我将Silex的“微框架”用于应用程序的路由目的。我现在正纠结于如何用.htaccess重写url。
标准Silex url: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]有什么建议吗?谢谢!
发布于 2015-11-19 22:53:30
我现在也遇到过同样的问题,解决方案是将.htaccess内容更改为:
FallbackResource /index.php所以在你的情况下,它将是
FallbackResource /web/index.php这对我很有效,我希望有人会发现它很有用。
发布于 2013-10-28 10:16:34
来自:http://silex.sensiolabs.org/doc/web_servers.html
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>正确的做法是将您的DocumentRoot设置为/path/to/your/app/web。
发布于 2013-03-18 05:03:57
下面这样的代码应该能起到作用:
RewriteEngine On
RewriteBase /
RewriteRule ^myapp/web/index.php/ /myapp/ [R=301,L]
RewriteRule ^myapp/ /myapp/web/index.php/ [L]https://stackoverflow.com/questions/15461091
复制相似问题