skip to Main Content

I have following structure of my project

root
   ra-cms-admin
      dist
         ra-cms-admin
            index.html
            ...
   ra-cms-public-and-api
      public
         index.php
         ...

ra-cms-admin is the single page application. I need when a user goes to / I want to redirect to ra-cms-public-and-api->public->index.php, and when the user goes to /admin (or /admin/something…) I want to redirect to single ra-cms-admin->dist->ra-cms-admin->index.html else I want to redirect always to to ra-cms-public-and-api->public->index.php (/something…).

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^admin ra-cms-admin/dist/index.html [L]
    RewriteRule ^ ra-cms-public-and-api/public/index.php [L]
</IfModule>

This app project is on my server in test folder.So when you want to access this app, you need to go localhost/test , but I have problem with admin section, when i put localhost/admin I am redirected still to public section… Any idea? According to https://htaccess.madewithlove.be/ my solutions should work, admin is matched…

2

Answers


  1. Can you try?

    RewriteRule ^admin ra-cms-admin/dist/ra-cms-admin/index.html [R=301,L]
    
    Login or Signup to reply.
  2. Move UP, or use RewriteCond.

    RewriteEngine On
    RewriteRule ^admin/(.+)$ /ra-cms-admin/dist/%1 [L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search