我正在使用 crud-admin-generator ( http://crud-admin-generator.com/ ) 为我的网络应用程序生成一个快速后端,它基于 silex 框架。
我的应用结构是:
MyApp
->index.php
->some_other_files
->...
->admin (the crud-admin-generator git clone)
->gen
->src
->vendor
->web
->controllers
->resources
->views
1) 当我访问管理员时,我目前需要使用 http://localhost/MyApp/admin/web
。我想删除 /web
部分。
我尝试在 admin
文件夹中创建自定义 htaccess
:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
但我不断收到错误消息:在此服务器上找不到请求的 URL/web/index.php。
2) 生成的管理面板使用 silex 框架,有没有一种简单的方法可以让我在前端使用 doctrine 组件或框架本身(admin 文件夹外的文件)?我是否需要手动更改所有生成的管理文件的路由路径?对不起,如果我听起来很困惑。
最佳答案
保持你的 /MyApp/admin/.htaccess
像这样:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /MyApp/admin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!web/).*)$ web/$1 [NC,L]
</IfModule>
关于php - 如何从我的 URL 中删除 "/web"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24952846/