Forum for discussing general topics related to Couch.
27 posts Page 3 of 3
@normis, slash inside the path is constant and no need to code it. Slash is needed in the end if you want to add support for your users to type in ziguri/
In your case it will also simplify debug.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
here you go:

Code: Select all

        location / {
                try_files $uri $uri/ $uri.html $uri.php?$query_string;
        }

        location /obj {
                try_files $uri $uri/ $uri.html $uri.php?$query_string;
                rewrite ^/obj$ /obj/;
                rewrite ^/obj/$ /obj.php last;
                rewrite ^/obj/.*?([^\.\/]*)$ /obj.php?pname=$1 last;
                rewrite "^/obj/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$" /obj.php?d=$1$2$3 last;
                rewrite ^/obj/[^\.]*?([^/\.]*)/?$ /obj.php?fname=$1 last;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }



works fine, apart from the routing URL.

about that slash, no difference if I do it this way:

Code: Select all
   <cms:route name='lv_obj' path='lv{:page_name}' />      
        <cms:route name='en_obj' path='en{:page_name}' />


Still http://DOMAIN.lv/obj/lv/ziguri won't match (actually, it doesn't even show the path to match, like I said before)
Clearly without slash inside path will never match even with correct rewrite.
path='lv/{:page_name}{:slash}'
is the correct path.

Slash is not solving your troubles, it makes solving a bit easier.

Edit:
I see your rule
rewrite ^/obj$ /obj/;

Without my suggestion it never matches to lv/ziguri, because lv/ziguri/ will be requested and it's a valuable difference.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Like this?

Code: Select all
      
<cms:route name='lv_obj' path='lv{:page_name}{:slash}' >
           <cms:route_constraints  slash='(\/?)'  />
</cms:route>   
<cms:route name='en_obj' path='en{:page_name}{:slash}' >
           <cms:route_constraints  slash='(\/?)'  />
</cms:route> 


still the same result
normis wrote: still the same result

You obviously missed slash inside. I'll repeat it again here.
path='lv/{:page_name}{:slash}'


I will also repeat my other words:
Slash is not solving your troubles, it makes solving a bit easier.


normis wrote: still the same result

You must make proper rewrite rules. Ending {:slash} only helps to match route if it's present in the end of path. I hope someone can help you with proper rewriting rules. If you manage to solve it yourself - please post solution.

Again, don't expect people dance around you. The requirements never mentioned nginx http://docs.couchcms.com/requirements.html and to get some help with something NOT related to CouchCMS, please be at least attentive to the advice here and read carefully.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
I knew I would start getting on peoples nerves eventually, sorry, man :)
I have a running system. I won't buy another server to run Apache. I have to work with what I have.

Anyway, I fixed it.

Here are the final working rules, if anyone needs them:

Code: Select all
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title='Apraksts' clonable='1' routable='1'>


<cms:route name='lv_obj' path='/lv/{:page_name}{:slash}' >
   <cms:route_constraints  slash='(\/?)'  />
</cms:route>   
<cms:route name='en_obj' path='/en/{:page_name}{:slash}' >
   <cms:route_constraints  slash='(\/?)'  />
</cms:route> 

Later my content:

<cms:if k_matched_route='lv_obj'>
   <cms:pages page_name=rt_page_name>
         .... latvian content
<cms:else_if k_matched_route='en_obj' />
        <cms:pages page_name=rt_page_name>
        .... english content
</cms:if>
...
<?php COUCH::invoke(K_IGNORE_CONTEXT); ?>



and my final NGINX rules:

Code: Select all
        location / {
                try_files $uri $uri/ $uri.html $uri.php?$query_string;
                rewrite /obj/(.*)(|/)$ /obj.php?q=$2/$1 last;

        }
Congrats! This will be very helpful for others :)
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
27 posts Page 3 of 3