我正在使用crud管理生成器(http://crud-admin-generator.com/)为我的web应用程序生成一个基于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>
但我一直收到一个错误:The requested URL /web/index.php was not found on this server.
2( 生成的管理面板使用silex框架,有没有一种简单的方法可以让我在前端使用条令组件或框架本身(管理文件夹外的文件(?我需要手动更改所有生成的管理文件的路由路径吗?如果我听起来很困惑,我很抱歉。
保持/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>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /mekaturk1/admin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!web/).*)$ web/$1 [NC,L,R]
</IfModule>
->web/$1[NC,L,R]很重要R
在电脑前搜索propper解决方案的时间越来越长,最后我找到了一个对我有用的解决方案:
步骤1:启用Apache重写模块
第2步:编辑.htaccess文件,使其看起来像以下几行
选项-多视图<IfModule mod_rewrite.c>重写引擎打开重写数据库/重写结束%{REQUEST_FILENAME}-f重写规则^index.php[QSA,L]<IfModule>
我希望它能起作用。
因为某种原因,它将是解决这个问题的变体,在我的情况下,我使用这个代码
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /MyApp/admin/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!web/).*)$ web/index.php [NC,L,R]
</IfModule>
对不起,我的英语太差了
尝试
RewriteRule ^(.*)/web$ /$1 [L,R=301]
我已经测试过,这些应该从url的末尾找到单词"web"。