Y
Y
yiicoder2014-10-27 20:48:17
PHP
yiicoder, 2014-10-27 20:48:17

How to rewrite routings from Apache to Nginx (split into backend\frontend)?

The project is divided into frontend\backend. The structure is
:
/
/...
/backend/www/...
/backend/www/index.php
/frontend/www/...
/frontend/www/index.php
when we access site.com/css/style.css the actual file is located at /frontend/www/css/style.css, if we access a non-existent file without extension, then the request falls to /frontend/www/index.php , but if the path starts with /admin/* then everything is the same only on the path /backend/www/....
Now everything works under apache, but I would like to get rid of it.
Organized now as follows:
at the root (document_root) is /.htaccess

RewriteEngine on
RewriteRule ^/?admin(.*)$ /backend/www/$1 [L]
RewriteRule (.*) frontend/www/$1 [last]

/frontend/www/.htaccess
/backend/www/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|bmp|css|js).* [NC]
RewriteRule (.*) index.php

How to repeat the same on nginx+phpfpm? Maybe someone has a similar configuration?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Power, 2014-10-27
@Power

What's the problem? Read the documentation : location, try_files, rewrite, ... And make up your own configuration. It is better not to look for a ready-made one on the net, because. full of examples with errors.

T
twixoff, 2014-10-27
@twixoff

Try winginx.com/ru/htaccess

L
LAV45, 2014-11-07
@LAV45

https://gist.github.com/LAV45/5f75aeb8f40f6ac4efa2
I usually separate frontend and backend into different subdomains.

http://site.com - frontend
http://admin.site.com - backend

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question