4

I am using the crud-admin-generator (http://crud-admin-generator.com/) to generate a quick backend for my web app, which is based on the silex framework.

My app structure is:

MyApp
  ->index.php
  ->some_other_files
  ->...
  ->admin (the crud-admin-generator git clone)
      ->gen
      ->src
      ->vendor
      ->web
         ->controllers
         ->resources
         ->views

1) When I access the admin I currently need to use http://localhost/MyApp/admin/web. I want to remove the /web part. I tried creating a custom htaccess in the admin folder with:

<IfModule mod_rewrite.c>
    Options -MultiViews    
    RewriteEngine On
    RewriteBase /web
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

But I keep getting an error: The requested URL /web/index.php was not found on this server.

2) The generated admin panel uses the silex framework, is there a easy way for me to use the doctrine component or the framework itself for my frontend as well (files outside the admin folder)? Would I need to manually change the routing paths of all the generated admin files? Sorry if I sound confused.

5 Answers 5

4

Keep your /MyApp/admin/.htaccess like this:

<IfModule mod_rewrite.c>
    Options -MultiViews    
    RewriteEngine On
    RewriteBase /MyApp/admin/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^((?!web/).*)$ web/$1 [NC,L]
</IfModule>
5
  • 1
    This might be something with my setup, but when I use this, I get a 500 error. And for some odd reason there is no record of this in the error log, so I can't debug it as well
    – Aoi
    Jul 25, 2014 at 11:04
  • Now it throws an error NotFoundHttpException in RouterListener.php line 145: No route found for "GET /MyApp/admin/"
    – Aoi
    Jul 25, 2014 at 17:27
  • For testing change rule to: RewriteRule ^((?!web/).*)$ web/$1 [NC,L,R]
    – anubhava
    Jul 25, 2014 at 17:35
  • That tells that rewrite rule is working fine but silex framework isn't liking internally rewritten URI like other frameworks such as WP etc. You will need to consult silex documentation for this as I don't know anything about it.
    – anubhava
    Jul 25, 2014 at 18:09
  • @zx81 Though I appreciate this answer, and the effort and time he took to help me, it didn't actually fix the issue, so I cannot mark this as accepted answer. I am sorry!
    – Aoi
    Jul 26, 2014 at 16:18
1
<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] is Important R

0

After hours and more hours in front of the computer googleing for the propper solution, finally i found the one that worked for me:

Step 1: Enable your Apache rewrite_module

Step 2: Edit your .htaccess file to look like the following lines

Options -MultiViews


<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [QSA,L]
</IfModule>

I hope it works.

0

because some reason, it will be variant to solve this problem, in my case i use this code

<IfModule mod_rewrite.c>
    Options -MultiViews    
    RewriteEngine On
    RewriteBase /MyApp/admin/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^((?!web/).*)$ web/index.php [NC,L,R]
</IfModule>

sorry, my english so bad

-1

Try

RewriteRule ^(.*)/web$ /$1 [L,R=301]

These should find the word "web" from the end of the url, I have tested.

1
  • This could use a little explanation as to what it does/why it should solve the problem.
    – TMH
    Jul 25, 2014 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.