老板需求想搞一个官网、然后有目标的抄袭网站、正常的做法需要迁移的东西非常的多,使用nginx的rewrite功能可以迅速的做一个静态网站的镜像
**
1.network扒取html文件放到/www/web/localhost下面
2.配置nginx
**
server {
listen 80;
server_name localhost;
root /www/web/localhost;
index index.htm index.php index.html;
error_page 400 /errpage/400.html;
error_page 403 /errpage/403.html;
error_page 404 /errpage/404.html;
error_page 405 /errpage/405.html;
//静态网页重写到本地的php文件
location ~ .*\.(htm|html) {
if ( !-e $request_filename) {
rewrite ^/(.*)$ /index.php;
}
expires 24d;
}
location ~ .*\.(js) {
if ( !-e $request_filename) {
rewrite ^/(.*)$ /dyx.php;
}
expires 24d;
access_log off;
}
//目标网站的静态资源地址
location ~ .*\.(css|gif|jpg|jpeg|png|bmp|swf|txt)$ {
if ( !-e $request_filename) {
rewrite ^/(.*)$ http://www.xxx.com/$1;
}
expires 24d;
access_log off;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}