Home | Tutoriale | Cum sa Web | WordPress reguli rewrite pentru Nginx

WordPress reguli rewrite pentru Nginx

In cazul in care esti posesorul fericit al unui pachet de gazduire sau un server cu Nginx probabil ca ai realizat ca htaccess nu mai functioneaza pentru a activa permament links, sau functioneaza si adauga acel index.php in totate link-urile.
Rezolvarea acestei probeleme este una simpla, poti adauga urmatorul cod in nginx.conf, sau poti solicita providerului tau sa iti adauge aceste directive pentru contul tau de gazduire.

# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
location / {
	try_files $uri $uri/ /index.php?$args;

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;

# Global restrictions configuration file.
location = /favicon.ico {
	log_not_found off;
	access_log off;
location = /robots.txt {
	allow all;
	log_not_found off;
	access_log off;

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~ /\. {
	deny all;

location ~ nginx.conf { deny all; }

# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
location ~* /(?:uploads|files)/.*\.php$ {
	deny all;

rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;

Directivele mentionate sunt doar pentru wordpress. Daca folosesti alt framework iti recomand sa folosesti acest site http://winginx.com/htaccess

About TotPeRo

Leave a Reply

Your email address will not be published. Required fields are marked *