rewrite after rewrite in nginx

i have:

  1. nginx server
  2. site based on joomla
  3. rewrite like this in server block

    location / {
     # Support Clean (aka Search Engine Friendly) URLs
     try_files $uri $uri/ /index.php?$args;
    }
    

this produces "sef like" links /abb/aaa/ccc

what i want now is to make map of short url's (of those rewrite links)

like this:

map @rewrite_url $rewrited_url {
    /a    /abb/aaa/ccc
    /b    /aaa/adddd/aaa
}

and this map to be applied

edit:

in location / try_files this :

/index.php?q=$request_uri; 

makes joomla url:

/index.php?bla=1&blab=2  ===> like "/aaa/aaa/aaa"  - > without  ?,& and =  

and i wanna make short form of this friendly(s) link(s) as include map to use:

/a instead of /bla/bla/comelink
/b instead of /bla/aaa/someotherlink

example (alias):

/changelog  /some/adres/to change-log/on/joomla/page
-1
задан 21 February 2016 в 22:15
1 ответ

хорошо, мне удалось отследить, почему он не работал, это было правописание при перезаписи базового URL-адреса карты

. Решение моей проблемы:

#redirect.map file content 
/target /destination/link;

#nginx http + server block 
map $request_uri $new_uri {
    include snippets/redirect.map;
}

server {

    location $reguest_uri  {
        if ($new_uri) {
           return 301 $new_uri;
        } 
    }

}
0
ответ дан 5 December 2019 в 20:30

Теги

Похожие вопросы