首頁  >  問答  >  主體

nginx偽靜態

偽靜態參數超過10個,怎麼寫
rewrite /index/([a-z]+)-(d+)-(.)-(.)-(d+)-(. )-(.)-(d+)-1-1-(d+)-(d+)-(d+).html$ /index.php?type=$1&cid=$2&q=$3&commission= $4&volume=$5&price_start=$6&price_end=$7&sort=$8&tmall=1&only=1&jr_update=$9&jr_insert=$10&page=$11 last;
後面的$10會解析成$1 0#{
{10}也不行啊

自問自答,過會在結貼吧!

我最後在罵一句!
賣假藥的百度快點倒閉吧!有你何用!搜尋只會推薦假藥! ! !
http://kzone.iteye.com/blog/1932104

rewrite /index/([a-z]+)-(d+)-(.)-(.)-(d+)-(.)-(.)- (d+)-1-1-(d+)-(?<n0>d+)-(?<n1>d+).html$ /index.php?type=$1&cid=$2&q=$3&commission=$4&volume =$5&price_start=$6&price_end=$7&sort=$8&tmall=1&only=1&jr_update=$9&jr_insert=$n0&page=$n1 last;
rewrite /index/([a-z]+)-(d+)-(. )-(.)-(d+)-(.)-(.)-(d+)-0-0-(d+)-(?<n0>d+)-(? <n1>d+).html$ /index.php?type=$1&cid=$2&q=$3&commission=$4&volume=$5&price_start=$6&price_end=$7&sort=$8&jrall=0&only=0&jr_update=$9&sort=$9&jrall=0&only=0&jr_update) $n1 last;
rewrite /index/([a-z]+)-(d+)-(.)-(.)-(d+)-(.)-(.)-(d+)-1-0-(d+)-(?<n0>d+)-(?<n1>d+).html$ /index.php?type=$1&cid=$2&q=$3 &commission=$4&volume=$5&price_start=$6&price_end=$7&sort=$8&tmall=1&only=0&jr_update=$9&jr_insert=$n0&page=$n1 last;
rewrite /index/([a-z]+ .)-(.)-(d+)-(.)-(.)-(d+)-0-1-(d+)-(?<n0>d+ )-(?<n1>d+).html$ /index.php?type=$1&cid=$2&q=$3&commission=$4&volume=$5&price_start=$6&price_end=$7&sort=$8&tmall=0&only=1&jr_ =$n0&page=$n1 last;

rewrite /index/([a-z]+)-(d+)-(.)-(.)-(d+)-(.)-(.)- (d+)-(d+)-1-(?<n0>d+)-(?<n1>d+).html$ /index.php?type=$1&cid=$2&q=$3&commission=$4&volume=$5 &price_start=$6&price_end=$7&sort=$8&tmall=$9&only=1&jr_update=$n0&page=$n1 last;
rewrite /index/([a-z]+)-(d+)-(.)-(. )-(d+)-(.)-(.)-(d+)-(d+)-0-(?<n0>d+)-(?<n1>d+) .html$ /index.php?type=$1&cid=$2&q=$3&commission=$4&volume=$5&price_start=$6&price_end=$7&sort=$8&tmall=$9&only=0&jr_update=$n0&page=$8&tmall=$9&only=0&jr_update=$n0&page=$n1 last;#

过去多啦不再A梦过去多啦不再A梦2713 天前710

全部回覆(2)我來回復

  • PHPz

    PHPz2017-05-16 17:19:31

    結貼,答案在我的問題裡

    回覆
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 17:19:31

    個人覺得這樣些是不是有點太不美觀了啊。可以考慮寫個內部路由或寫個跳轉規則也行吧,例如:
    偽靜態寫成:

    rewrite ^/(.*?) /index.php?location= last;

    php頁中新增規則:

    $location = $_GET['location'];
    $tag = '-';
    $paramter_key = array('type', 'cid', 'q', 'commission', 'volume', 'price_start', 'price_end', 'sort', 'tmall', 'only', 'js_update', 'jr_insert', 'page');
    $paramter_value = explode($tag, $location);
    
    //url参数及对应值形成的数组
    $paramter = array_combine($paramter_key, $paramter_value);
    //也可以把数组形式打散为变量形式
    extract($paramter);
    
    /**
     * 使用变量
     * echo $paramter['type'];
     * or
     * echo $type;
     */

    回覆
    0
  • 取消回覆