Li muitos tópicos sobre isso, mas não consegui resolver meu problema.
Depois de passar do APache para o Nginx, não consigo definir novas regras para lidar com os URLs amigáveis do fórum.
Meus fóruns estão em / forum / location do servidor virtual. Tudo o que quero fazer é reescrever /forum/thred-something.html&someaction em /forum/showthread.php?tid=ID&action=someaction
Eu uso este plug-in para a conversão de nome para identificação: link
É assim que minha configuração de localização do servidor virtual se parece:
server {
server_name www.podziemieopowiadan.pl;
listen 80;
return 301 http://podziemieopowiadan.pl/index.php;
}
server
{
server_name podziemieopowiadan.pl;
listen 80;
access_log /var/log/nginx/podziemieopowiadan-pl_access_log;
error_log /var/log/nginx/podziemieopowiadan-pl_error_log;
root /var/www/domains/podziemieopowiadan-old;
index index.php;
allow 188.127.246.50;
allow 188.127.242.122;
allow 204.93.240.0;
allow 204.93.177.0;
allow 199.27.128.0;
allow 173.245.48.0;
allow 103.21.244.0;
allow 103.22.200.0;
allow 103.31.4.0;
allow 141.101.64.0;
allow 108.162.192.0;
allow 190.93.240.0;
allow 188.114.96.0;
allow 197.234.240.0;
allow 198.41.128.0;
allow 162.158.0.0;
include global.conf;
location /forum/{
index index.html index.php;
rewrite ^/([^&]*)&(.*)$ http://podziemieopowiadan.pl/forum/$1?$2 permanent;
rewrite ^/((?i)sitemap-([^./]+)\.xml)$ /forum/misc.php?google_seo_sitemap=$2 last;
rewrite ^/((?i)forum-([^./]+)\.html)$ /forum/forumdisplay.php?google_seo_forum=$2 last;
rewrite ^/((?i)thread-([^./]+)\.html)$ /forum/showthread.php?google_seo_thread=$2 last;
rewrite ^/((?i)announcement-([^./]+)\.html)$ /forum/announcements.php?google_seo_announcement=$2 last;
rewrite ^/((?i)user-([^./]+)\.html)$ /forum/member.php?action=profile&google_seo_user=$2 last;
rewrite ^/((?i)calendar-([^./]+)\.html)$ /forum/calendar.php?google_seo_calendar=$2 last;
rewrite ^/((?i)event-([^./]+)\.html)$ /forum/calendar.php?action=event&google_seo_event=$2 last;
}
location ~ \.php$
{
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param REDIRECT_URL $request_uri;
}
}
E aqui está o código .htaccess que eu estava tentando recriar (sugerido pelo próprio plugin):
RewriteEngine on
RewriteBase /forum/
RewriteRule ^([^&]*)&(.*)$ http://podziemieopowiadan.pl/forum/$1?$2 [L,QSA,R=301]
ErrorDocument 404 /forum/misc.php?google_seo_error=404
RewriteRule ^sitemap\-([^./]+)\.xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC]
RewriteRule ^forum\-([^./]+)\.html$ forumdisplay.php?google_seo_forum=$1 [L,QSA,NC]
RewriteRule ^thread\-([^./]+)\.html$ showthread.php?google_seo_thread=$1 [L,QSA,NC]
RewriteRule ^announcement\-([^./]+)\.html$ announcements.php?google_seo_announcement=$1 [L,QSA,NC]
RewriteRule ^user\-([^./]+)\.html$ member.php?action=profile&google_seo_user=$1 [L,QSA,NC]
RewriteRule ^calendar\-([^./]+)\.html$ calendar.php?google_seo_calendar=$1 [L,QSA,NC]
RewriteRule ^event\-([^./]+)\.html$ calendar.php?action=event&google_seo_event=$1 [L,QSA,NC]
Meu nginx.conf:
user www-data;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 256;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 2m;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
##
# Page Speed Configuration
##
#pagespeed on;
#pagespeed FileCachePath /var/ngx_pagespeed_cache;
#pagespeed CreateSharedMemoryMetadataCache "/var/ngx_pagespeed_cache" 102400;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
E meu global.conf:
# Ustawianie naglowkow expires
location ~* \.(?:ico|js|gif|jpe?g|png)$
{
expires 24h;
access_log off;
log_not_found off;
}
# Blokada dostepu + wylaczanie logowania
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
# Cloudflare
set_real_ip_from 204.93.240.0/24;
set_real_ip_from 204.93.177.0/24;
set_real_ip_from 199.27.128.0/21;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
set_real_ip_from 162.158.0.0/15;
real_ip_header CF-Connecting-IP;
# Blokada dostepu do specyficznych danych
#location ~ cache/(.*)$
#{
# deny all;
#}