apache,nginx

# apache rewrite
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /AltoRouter/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /AltoRouter/index.php [L]
</IfModule>
# END WordPress

#for nginx, for test
server{
	listen		80;
	server_name	xyz.com;
	index		index.php index.html;
	#root		/usr/share/nginx/html;
	root		/home/xyz/wwwroot;
	access_log	off;

	location / {
            index index.php index.html index.htm;
            #如果请求即不是一个文件,也不是一个目录
            if (!-e $request_filename){
                #地址作为将参数rewrite到index.php上。
                #rewrite ^/(.*)$ /index.php/$1;
                #若是子目录则使用下面这句,将folder改成目录名称即可。
                rewrite ^/AltoRouter/(.*)$ /AltoRouter/index.php/$1;              }
#		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;
#		}
	}
	
	location ~ \.php {
		autoindex on;
		#root		/usr/share/nginx/html;
		#fastcgi_pass	127.0.0.1:9000;
		fastcgi_pass	unix:/var/run/php5-fpm.sock;
		fastcgi_index	index.php;
		include		/etc/nginx/fastcgi_params;
		#fastcgi_param	SCRIPT_FILENAME	/user/share/nginx/html$fastcgi_script_name;
		fastcgi_param	SCRIPT_FILENAME	$document_root$fastcgi_script_name;
		#fastcgi_pass	127.0.0.1:10768;
                
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
		
                #pathinfo support 
                set $path_info "";
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
                }
	}
}

你可能感兴趣的:(apache,nginx)