Am incercat acum de cateva ori dar nu merge. Am un server care rulează Debian 10 cu NGINX și Wordpress instalate.
Acum trebuie să rescriu câteva adrese URL vechi în noul loc.
Trebuie să rescriem URL-uri astfel:
example.com/artikel.html?id=##ID##&meldung=###Meldung### la example.com/artikel/$2
nume_server example.com www.example.com;
rădăcină /var/www/example.com;
index index.html index.htm index.php;
access_log /var/log/nginx/example.com_access.log;
error_log /var/log/nginx/example.com_error.log;
setați $skip_cache 0;
dacă ($request_method = POST) {
setați $skip_cache 1;
}
if ($query_string != "") {
setați $skip_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php
|sitemap(_index)?.xml") {
setați $skip_cache 1;
}
dacă ($http_cookie ~* "autor_comentarii|wordpress_[a-f0-9]+|wp-postpass
|wordpress_no_cache|wordpress_logged_in") {
setați $skip_cache 1;
}
locație /Artikel {
rescrie ^/Artikel.html(.*)$ https://example.com/artikel break;
}
Locație / {
add_header Front-End-Https activat;
add_header Cache-Control „public, trebuie revalidat”;
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
try_files $uri $uri/ =404 @rewrite;
proxy_set_header Gazdă $gazdă;
proxy_set_header X-Real-IP $adresă_la distanță;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
locație @rewrite {
rescrie ^/Artikel.html$ /kontakt permanent;
rescrie ^/Artikel\.html /artikel redirect;
rescrie ^/test/(.*)/$ example2.com/test($1) permanent;
rescrie ^/artikel.html?id=(.*)&meldung=(.*)$ https://example.com/artikel/$2 permanent;
}
locație ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
}
locație ~ /\.ht {
nega totul;
}
locație ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2 |doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expira max;
}
locație ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expira max;
log_not_found off;
}
locație ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ {
nega totul;
}
locație ~* wp-config.php {
nega totul;
}
locație = /robots.txt {
access_log off;
log_not_found off;
}
locație ~ /. {
nega totul;
access_log off;
log_not_found off;
}
dacă (!-e $nume_fișier_cerere) {
rescrie ^.* /index.php pauză;
}
asculta 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
includ /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
Server {
dacă ($gazdă = exemplu.com) {
returnează 301 https://$host$request_uri;
}
dacă ($gazdă = example.com.com) {
returnează 301 https://$host$request_uri;
}
asculta 8080;
server_name example.com www.example.com;
întoarce 404;
}
Aștept cu nerăbdare să aud de la tine în curând.
Vă mulțumim anticipat pentru eforturile dvs.