modx 友好 url nginx FPM php5.3 - 友好 url 不起作用

发布于 2024-10-08 22:08:48 字数 1824 浏览 3 评论 0原文

我在 nginx 0.8.53 上使用 php5.3,在 Modx Revolution 上使用 FPM。

我试图让“友好的网址”工作,但我得到的只是 404。 在 modx 配置中,友好的 url 设置为 yes,友好的别名设置为 no(因此它会删除后缀)

我的配置文件:

server {
    listen 80;
    server_name .mydomain.net;

    # index index.php;
    root   /home/mylogin/htdocs;

    location /  {
             index  index.php index.html;
             if (!-e $request_filename)
             {
               rewrite ^/(.*)$ /index.php?q=$1 last;
             }
    }
    # serve static files directly
    location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
        root /home/mylogin/htdocs;
        access_log        off;
        expires           30d;
        break;
    }
}

Fast CGI modx 文件:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_ignore_client_abort on;
fastcgi_intercept_errors on;
fastcgi_read_timeout 300;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;

Im using php5.3 on nginx 0.8.53 with FPM on Modx revolution.

Im trying to get "friendly url's" to work, but all I get is 404's.
In modx config, friendly url's is set to yes, friendly aliases is set to no (so it drops the suffix)

My config file:

server {
    listen 80;
    server_name .mydomain.net;

    # index index.php;
    root   /home/mylogin/htdocs;

    location /  {
             index  index.php index.html;
             if (!-e $request_filename)
             {
               rewrite ^/(.*)$ /index.php?q=$1 last;
             }
    }
    # serve static files directly
    location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
        root /home/mylogin/htdocs;
        access_log        off;
        expires           30d;
        break;
    }
}

Fast CGI modx file:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_ignore_client_abort on;
fastcgi_intercept_errors on;
fastcgi_read_timeout 300;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

与之呼应 2024-10-15 22:08:48

不太可能是完整的解决方案,但您的设置是错误的 - “友好别名”是关于是否在资源中使用“别名”作为 FURL 端点的设置。如果您想删除后缀,请进入“系统设置”>“后缀”。内容类型并将 HTML 设置为空白。

Unlikely to be the complete solution but your settings are wrong - 'friendly aliases' is the setting as to whether to use 'alias' in the resource as the endpoint for a FURL. If you want to remove the suffix, go to System Settings > Content types and set HTML to blank.

空城旧梦 2024-10-15 22:08:48

请使用此默认配置

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    # try_files $uri $uri/ =404; //Comment this and add below line
      try_files $uri $uri/ /index.php?$args;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

}

pleas use this default configuration

server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

root /usr/share/nginx/html;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

location / {
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    # try_files $uri $uri/ =404; //Comment this and add below line
      try_files $uri $uri/ /index.php?$args;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root /usr/share/nginx/html;
}
location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文