Heim > Fragen und Antworten > Hauptteil
Idee:
http://abc.ccav.com umschreiben zu http://www.ccav.com/uid/abc
http://abc.ccav.com/article/index/index umschreiben zu http:// www.ccav.com/article/index/index/uid/abc
http://abc.ccav.com/article/index/show/id/1 Umschreiben in http://www.ccav.com/article/index /show/uid/abc/id/1
http://abc.ccav.com/shop/index/index umschreiben in http://www.ccav.com/shop/index/index/uid/abc
http: //abc.ccav.com/shop/index/show/id/1 umschreiben in http://www.ccav.com/shop/index/show/uid/abc/id/1
Ich habe es tatsächlich ein paar Mal versucht, bin aber gescheitert. Bitte geben Sie mir einen Rat
大家讲道理2017-05-16 17:25:29
自己解决了
server {
listen 80;
#rewrite_log on;
#error_log /datas/logs/ccav_rewrite.log notice;
server_name *.u.ccav.com;
location ~ ^/(images|styles|scripts|uploads)/
{
proxy_redirect off;
proxy_set_header Host www.ccav.com;
proxy_pass http://127.0.0.1:80;
}
location / {
set $uid default;
if ( $http_host ~* "^(.*)\.u\.ccav\.com") {
set $uid $1;
}
rewrite ^/article/index/show/id/([0-9]+)/?$ /article/index/show/uid/$uid/id/$1 break;
rewrite ^/article/index/index/?$ /article/index/index/uid/$uid break;
rewrite ^/article/index/category/cid/([0-9]+)/?$ /article/index/category/uid/$uid/cid/$1 break;
proxy_pass http://www.ccav.com;
}
}
PHP中文网2017-05-16 17:25:29
这是不重写,应该叫跳转,可以做301,当$host = 'abc.ccav.com' 时,^/(.*)$ http://www.ccav.com/$1 permanent; 思路就是这样的