打zZ~瞌睡 Menu

Nginx中WordPress、Joomla、Drupal的URL重写配置

Drupal

location / {
	if (!-e $request_filename) {
		rewrite ^/(.*)$ /index.php?q=$1 last;
	}
}

 

Joomla

location / {
	if ( $args ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3d)" ) {
		set $args "";
		rewrite ^.*$ http://$host/index.php last;
		return 403;
	}
 
	if ( $args ~ "base64_encode.*\(.*\)") {
		set $args "";
		rewrite ^.*$ http://$host/index.php last;
		return 403;
	}
 
	if ( $args ~ "(\<|%3C).*script.*(\>|%3E)") {
		set $args "";
		rewrite ^.*$ http://$host/index.php last;
		return 403;
	}
	
	if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})") {
		set $args "";
		rewrite ^.*$ http://$host/index.php last;
		return 403;
	}
	
	if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})") {
		set $args "";
		rewrite ^.*$ http://$host/index.php last;
		return 403;
	}
	
	if (!-e $request_filename) {
		rewrite (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ /index.php last;
		break;
	}
 
}

 

WordPress

location / {
	if (-f $request_filename/index.html) {
		rewrite (.*) $1/index.html break;
	}
	if (-f $request_filename/index.php) {
		rewrite (.*) $1/index.php;
	}
	if (!-f $request_filename) {
		rewrite (.*) /index.php;
	}
}