Jump to content

Nginx Api rewrite rules

Recommended Posts

Hello guys,

im running invision on nginx and want to access the REST api. Since i cant use .htaccess files i need to edit the nginx server config.

I tried different approaches setting up the rewrite rules but it always gives me this error:

The API endpoint is not giving the expected response. Check you followed the instructions correctly. The URL being tested is: https://xxxxx.com/api/core/hello


Board settings:

Enable Friendly URLs? - Active

Rewrite URLs?  - Active

Force Friendly URLs? - Active


nginx server cfg:

server {
 listen 80;
 listen [::]:80;

 client_max_body_size    20M;

 root /var/www/html;
 index index.php index.html index.htm index.nginx-debian.html;

 server_name xxxxx.com *.xxxxx.com;

 location / {
 # First attempt to serve request as file, then
 # as directory, then fall back to displaying a 404.
 #try_files $uri $uri/ =404;

 try_files  $uri $uri/ /index.php;

 location /api/ 
        rewrite ^/api/(.*)$ /api/index.php;

    #matches any path that starts with /forums
    #it tries to match the url to a file, then to a directory
    #and finally to the forum index file in /forums/index.php
    #location /forums {
    #    try_files $uri $uri/ /forums/index.php;

 # pass the PHP scripts to FastCGI server listening on
 location ~ \.php$ {
 include snippets/fastcgi-php.conf;

 # With php7.0-cgi alone:
 # fastcgi_pass;
 # With php7.0-fpm:
 fastcgi_pass unix:/run/php/php7.0-fpm.sock;

 # deny access to .htaccess files, if Apache's document root
 # concurs with nginx's one
 location ~ /\.ht {
  deny all;


Support told me to contact the community so: Can somebody help me? Id really appreciate it!

Thanks in advance!

Link to comment
Share on other sites

  • 1 month later...
48 minutes ago, Mark H said:

If you use Apache rather than nginx, make sure mod_rewrite is installed and active. If it is and still won't work, please open a ticket to support so we can take a look at your install.

well i use apache2 and mod rewrite ist active but it dont work.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...