阻止nginx重定向到index.php

时间:2021-10-24 19:59:27

I have installed nginx, php5-fpm and then owncloud. I have edited nginx configuration files as given in this tutorial. Now all my HTTP requests are redirected to index.php and I cannot cancel that! I have tried everything, but still no chance. I am a Linux and nginx beginner, so please bear with me.

我已经安装了nginx,php5-fpm,然后是owncloud。我编辑了本教程中给出的nginx配置文件。现在我的所有HTTP请求都被重定向到index.php,我无法取消它!我已经尝试了一切,但仍然没有机会。我是Linux和nginx初学者,所以请耐心等待。

This is the contents of my /etc/nginx/siets-available/mysite:

这是我的/ etc / nginx / siets-available / mysite的内容:

server {
  listen 80;
  root /var/www;
  index index.html index.htm;
}

Contents of /etc/nginx/sites-enabled:

/ etc / nginx / sites-enabled的内容:

mysite

Contents of /var/www:

/ var / www的内容:

index.html tulips.png

index.html is a simple html with tulips.png inside. No redirection in HTML.

index.html是一个简单的html,里面有tulips.png。 HTML中没有重定向。

The problem is not on the PHP side, because when I stop php5-fpm service, the redirection still occurs.

问题不在PHP方面,因为当我停止php5-fpm服务时,重定向仍然会发生。

I have walked the tutorial all backwards, but cannot restore the original state. All pages keep redirecting to index.php. Please help me to cancel that redirection.

我已经向后走了教程,但无法恢复原始状态。所有页面都会重定向到index.php。请帮我取消重定向。

2 个解决方案

#1


1  

Looking at the tutorial,

看看教程,

Do you have a line that looks like this?

你有一条看起来像这样的线吗?

try_files $uri $uri/ index.php;

This will attempt to serve the file specified by the URI in relation to the root (or alias). If the file is not found nginx will then redirect you to index.php.

这将尝试提供URI相对于根(或别名)指定的文件。如果找不到该文件,则nginx会将您重定向到index.php。

I hope this helps, but we must be missing something...

我希望这会有所帮助,但我们必须遗漏一些东西......

P.S.

附:

I'm assuming you've tried restarting Nginx (sudo service nginx restart). Nginx won't read the configuration files until you do this. (Or sudo service nginx reload).

我假设你已经尝试重启Nginx(sudo服务nginx重启)。在您执行此操作之前,Nginx不会读取配置文件。 (或sudo服务nginx重新加载)。

#2


0  

Try Adding this to website and see if it works:

尝试将此添加到网站,看看它是否有效:

location / {
    try_files $uri $uri/
}

More details about try_files: http://wiki.nginx.org/HttpCoreModule#try_files.

有关try_files的更多详细信息:http://wiki.nginx.org/HttpCoreModule#try_files。

#1


1  

Looking at the tutorial,

看看教程,

Do you have a line that looks like this?

你有一条看起来像这样的线吗?

try_files $uri $uri/ index.php;

This will attempt to serve the file specified by the URI in relation to the root (or alias). If the file is not found nginx will then redirect you to index.php.

这将尝试提供URI相对于根(或别名)指定的文件。如果找不到该文件,则nginx会将您重定向到index.php。

I hope this helps, but we must be missing something...

我希望这会有所帮助,但我们必须遗漏一些东西......

P.S.

附:

I'm assuming you've tried restarting Nginx (sudo service nginx restart). Nginx won't read the configuration files until you do this. (Or sudo service nginx reload).

我假设你已经尝试重启Nginx(sudo服务nginx重启)。在您执行此操作之前,Nginx不会读取配置文件。 (或sudo服务nginx重新加载)。

#2


0  

Try Adding this to website and see if it works:

尝试将此添加到网站,看看它是否有效:

location / {
    try_files $uri $uri/
}

More details about try_files: http://wiki.nginx.org/HttpCoreModule#try_files.

有关try_files的更多详细信息:http://wiki.nginx.org/HttpCoreModule#try_files。