php - Silex 路由 .htaccess webroot

标签 php .htaccess routing silex

我将 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/

相关文章:

php - CSS 和图像不会在页面加载时加载,但会在页面刷新时加载

php - 收到来自 Controller 的请求后,CodeIgniter 显示 div

php - htaccess 文件 : Force going to https instead of http except for specific pages

PHP登录页面代码问题。登录页面加载消息显示无效登录

.htaccess - CORS问题请求的资源上不存在 'Access-Control-Allow-Origin' header

react-native - react 原生 : TypeError: undefined is not an object (evaluating 'this.props.navigation.navigate' )

php - Symfony2 路由 - 路由子域

symfony - 覆盖路由器并将参数添加到特定路由(在使用路径/url 之前)

php - 让 MySQL 找出日期间隔与 PHP

php - 查找相同的表行