使用Nginx在MAMP上启用SEF后出现404错误

时间:2016-08-07 20:40:30

标签: nginx joomla mamp joomla3.0

有人设法在 MAMP 3.5.2 上使用 Nginx 使用Joomla SEF吗? 在我打开SEF选项之前,在localhost上工作的网站很好,主页有效,但任何其他链接都会出现404错误。我尝试了所有不同的配置而没有运气。 有人可以帮忙吗?

我的nginx.conf是:

User                               root admin;
worker_processes                   2;

events {
      worker_connections          1024;
}

http {
      include                    mime.types;
      default_type                   text/html;
   gzip                               on;
   gzip_types                      text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;

      sendfile  on;
      client_max_body_size 200M;

   server {
      listen  80 default_server;
    server_name localhost;
      server_name_in_redirect off;

    access_log  /Applications/MAMP/logs/nginx_access.log;
      error_log /Applications/MAMP/logs/nginx_error.log debug;

      root  "/Applications/MAMP/htdocs";
      index index.php index.html index.htm  default.html  default.htm;

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

    location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                  return 403;
                  error_page 403 /403_error.html;
      }

    location ~ \.php$ {
    try_files            $uri =404;
    fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
    fastcgi_index index.php;
    fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include               fastcgi_params;
    include fastcgi.conf;
    }

      location ~* /MAMP/(.*)$ {
         root                   /Applications/MAMP/bin;
         index                  index.php;

         location ~ \.php$ {
      try_files            $uri =404;
      fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
      fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include               fastcgi_params;
         }
      }

      location ~* /phpMyAdmin(.*)$ {
         root                   /Applications/MAMP/bin;
         index                  index.php;

         location ~ \.php$ {
            try_files            $uri =404;
            fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
            fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include               fastcgi_params;
         }
      }

      location ~* /phpPgAdmin(.*)$ {
         root                   /Applications/MAMP/bin;
         index                  index.php;

         location ~ \.php$ {
            try_files            $uri =404;
            fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
            fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include               fastcgi_params;
         }
      }

      location ~* /phpLiteAdmin(.*)$ {
         root                   /Applications/MAMP/bin;
         index                  index.php;

         location ~ \.php$ {
            try_files            $uri =404;
            fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
            fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include               fastcgi_params;
         }
      }

      location ~* /SQLiteManager(.*)$ {
         root                   /Applications/MAMP/bin;
         index                  index.php;

         location ~ \.php$ {
            try_files            $uri =404;
            fastcgi_pass       unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock;
            fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include               fastcgi_params;
         }
      }

      location /icons {
         alias /Applications/MAMP/Library/icons;
         autoindex on;
      }

      location /favicon.ico {
         alias /Applications/MAMP/bin/favicon.ico;
                  # log_not_found off;
                  # access_log off;
      }

      location ~ /\. {
         deny all;
      }

      # location ~* \.(gif|jpg|png|pdf)$ {
            #   expires               30d;
      # }

          # location = /robots.txt {
            #   allow all;
            #   log_not_found off;
            #   access_log off;
          # }

         # location ~* \.(txt|log)$ {
            #   allow 127.0.0.1;
            #   deny all;
          # }

          # location ~ \..*/.*\.php$ {
            #   return 403;
          # }

      location /nginx_status {
         stub_status         on;
         access_log          off;
         allow                  127.0.0.1;
         deny          all;
      }
   }

      # HTTPS server
      #
      #server {
      #      listen          443 ssl;
      #      server_name   localhost;

      #      ssl_certificate         cert.pem;
      #      ssl_certificate_key   cert.key;

      #      ssl_session_cache      shared:SSL:1m;
      #      ssl_session_timeout   5m;

   #    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      #      ssl_ciphers   HIGH:!aNULL:!MD5;
      #      ssl_prefer_server_ciphers   on;

      #      location / {
      #            root    html;
      #            index   index.html index.htm;
      #      }
      #}
}

1 个答案:

答案 0 :(得分:0)

请正确按照上述说明在NGIX服务器中启用sef。

JOOMLA SEF in NGIX