Как составить правила для htaccess

A
На сайте с 18.10.2007
Offline
125
1059

Переношу чужой проект на свой сервер. Переадресация на старом сервере была настроена через конфиг nginx, примерно так


location ~ /api {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/web/index.php$is_args$args;
fastcgi_param HTTPS off;
}

#return 404 for all php files as we do have a front controller
#location ~ \.php$ {
# return 404;
#}

error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;

У себя пытаюсь настроить аналогичные правила через .htaccess, но не работает. Кто подскажет?


RewriteEngine On
RewriteBase /

RewriteRule ^api(.*)$ web/index.php?args=api$1 [L,QSA]

ErrorDocument 404 /

Сейчас получил полный конфиг nginx


server {
server_name www.domain2.com;
rewrite ^ http://domain.com$request_uri? permanent; #301 redirect
}

server {
root /home/user/sites/domain;
index index.html index.htm index.php;
server_name 111.222.333.444 domain.com *.domain.com;

location / {
index index.html index.php;
try_files $uri /index.html$is_args$args;
}

location ~ /api {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/web/index.php$is_args$args;
fastcgi_param HTTPS off;
}

#return 404 for all php files as we do have a front controller
#location ~ \.php$ {
# return 404;
#}

error_log /var/log/nginx/project_error.log;
access_log /var/log/nginx/project_access.log;

}
Только те, кто предпринимают абсурдные попытки, смогут достичь невозможного.
L
На сайте с 10.02.2015
Offline
222
#1

А какую ошибку выдает?

Может, перед web нужен "/"?

args можно не передавать, а парсить $_SERVER['REQUEST_URI'].

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий