php - 如何从我的 URL 中删除 "/web"?

标签 php .htaccess crud silex

我正在使用 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/

相关文章:

rest - Play Framework CRUD

php - 在数据库中找不到转义字符串

node.js - MEAN 堆栈 CRUD 更新 404 错误

php - CURL PHP - 缺少输出和未知错误

php - 我应该在现有规则中添加什么 RewriteRule 来解决这个问题?

php - 需要为目录页面编写 htaccess 规则

c++ - 在主机上设置 .htaccess 以执行 C++ cgi 脚本

c# - 想要使用 CRUD 操作在 asp.net c# 中创建 GridView 。请给我插入、更新、删除查询

PHP 5.x strtotime 无法正确解析英国格式 d-m-y

php - 在 PHP 中输​​出变量的 if 语句的优雅替代