Jump to content
  • 0

Nginx Rewrite Oddity - Front End Links Ok, Backend Links Not?


eva2000

Question

Hi I just started a 30 day trial for Blesta 3.4.3 to see if it's suited for my use on my Centmin Mod LEMP stack based Nginx/PHP-FPM/MariaDB setup.

 

Installation went fine but with friendly nginx rewritten urls came across an oddity that from forum search, I don't think I've come across.

 

friendly urls is enabled by setting lib/init.php

 
// define("HTACCESS", file_exists(ROOTWEBDIR . ".htaccess"));
define("HTACCESS", true);

 
And then i've tried everyone of this forums nginx rewrite formats populated throughout this forum via search and all result in the same.
 
Front end client side links work as friendly urls when clicked direct to right place
 
i.e.
However, backend admin urls within ONLY the nav links are NOT friendly urls and when clicked redirect to front page at http://newdomain.com
 
i.e.

these all redirect to front page at http://newdomain.com when clicked when define("HTACCESS", true); is set. If I unset define("HTACCESS", true);, then those links in nav area work
 
Backend admin urls NOT within nav links work as friendly urls though
 
i.e. these work
 
So is it something to do with the template or links coded in nav links ? As I tried every version of nginx rewrite rules found on this forum and the same odd symptoms outlined above occur in all instances ?
 
 
Some screenshots on localhost install
 
post-11219-0-43705200-1432535004_thumb.p
 
post-11219-0-45482700-1432535005_thumb.p
 
post-11219-0-34977400-1432535006_thumb.p
 
System config
  • CentOS 7.1 64bit
  • Virtualbox 4 with Centmin Mod LEMP stack
  • Nginx 1.9.0
  • PHP-FPM 5.4.41
  • MariaDB 10.0.19
  • CSF Firewall

Nginx config

 

 

nginx -V

nginx version: nginx/1.9.0
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) 
built with OpenSSL 1.0.2a 19 Mar 2015
TLS SNI support enabled
configure arguments: --with-ld-opt=-Wl,-rpath,/usr/local/lib --sbin-path=/usr/local/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_sub_module --with-http_addition_module --with-http_image_filter_module --with-http_secure_link_module --with-http_flv_module --with-http_realip_module --with-http_geoip_module --with-openssl-opt=enable-tlsext --add-module=../ngx-fancyindex-ngx-fancyindex --add-module=../ngx_cache_purge-2.3 --add-module=../headers-more-nginx-module-0.25 --add-module=../nginx-accesskey-2.0.3 --add-module=../nginx-http-concat-master --with-http_dav_module --add-module=../nginx-dav-ext-module-0.0.3 --add-module=../openresty-memc-nginx-module-1518da4 --add-module=../openresty-srcache-nginx-module-ffa9ab7 --add-module=../ngx_devel_kit-0.2.19 --add-module=../set-misc-nginx-module-0.28 --add-module=../echo-nginx-module-0.57 --add-module=../lua-nginx-module-0.9.16rc1 --add-module=../lua-upstream-nginx-module-0.02 --add-module=../lua-upstream-cache-nginx-module-0.1.1 --add-module=../nginx_upstream_check_module-0.3.0 --with-openssl=../openssl-1.0.2a --with-libatomic --with-threads --with-stream --with-stream_ssl_module --with-pcre=../pcre-8.37 --with-pcre-jit --with-http_spdy_module --add-module=../ngx_pagespeed-release-1.9.32.3-beta
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Everything is fine with your parameters. Using also Nginx my install work like you, and certainly it's the same with any other webserver.

 

My feeling about friendly URL, SEO, etc....... is it only related to FRONTEND and not related to BACKEND.

 

I think this is not only for Blesta but for a lot of CMS, all about SEO and search engine is for the FRONTEND by essence, as search engine can not index content for BACKEND that require being login.

Link to comment
Share on other sites

  • 0

in your vhost file for your domain (for debian it's under: /etc/nginx/sites-available)

 

before the php location block, have you this:

 ## Your only path reference.
        root /MY-FULL-PATH-TO-BLESTA-INSTALL/ ;

        
        index index.html index.htm index.php;
 




    #Core rewrite
    location @blesta {
         rewrite ^(.*)$ /index.php last;
 #      rewrite ^(.*)$ /index.php/(.*) /$1  permanent;
    }

and just before the end of the "server" block:

if (!-e $request_filename){
rewrite ^(.*)$ /index.php;
}







#Core rewrite
location @blesta {
        rewrite ^(.*)$/index.php/(.*) /$1  permanent;
}

and restart 1/ php5-fpm   2/ nginx

Link to comment
Share on other sites

  • 0

thanks Serge.. I got it working and it was something you reminded me to do, I forgot to restart php-fpm service after making the changes ! :lol: LOL I was only restarting Nginx !

 

it works now with backend admin nav links with friendly urls :)

 

There seems to be a few Centmin Mod LEMP stack users on this forum using Blesta, so here's the nginx vhost I have for my Centmin Mod LEMP stack's Nginx vhost

# Centmin Mod Getting Started Guide
# must read http://centminmod.com/getstarted.html

# redirect from non-www to www 
# uncomment, save file and restart Nginx to enable
# if unsure use return 302 before using return 301
#server {
#            listen   80;
#            server_name newdomain.com;
#            return 301 $scheme://www.newdomain.com$request_uri;
#       }

server {
  server_name newdomain.com www.newdomain.com;

# ngx_pagespeed & ngx_pagespeed handler
#include /usr/local/nginx/conf/pagespeed.conf;
#include /usr/local/nginx/conf/pagespeedhandler.conf;
#include /usr/local/nginx/conf/pagespeedstatslog.conf;

  # limit_conn limit_per_ip 16;
  # ssi  on;

  access_log /home/nginx/domains/newdomain.com/log/access.log combined buffer=256k flush=60m;
  error_log /home/nginx/domains/newdomain.com/log/error.log;

  root /home/nginx/domains/newdomain.com/public;

location ~ (\.pdt) {
return 403;
}

location / {
        try_files $uri $uri/ /index.php?$args;
}

  include /usr/local/nginx/conf/staticfiles_blesta.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
}

for /usr/local/nginx/conf/staticfiles_blesta.conf include file it's just created from default /usr/local/nginx/conf/staticfiles.conf with a css and html context locations commented out

cp -a /usr/local/nginx/conf/staticfiles.conf /usr/local/nginx/conf/staticfiles_blesta.conf
    location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso)$ {
        gzip_static off;
        #add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 30d;
        break;
        }

    location ~* \.(js)$ {
        #add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 30d;
        break;
        }

#    location ~* \.(css)$ {
#       #add_header Pragma public;
#       add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#       access_log off;
#       expires 30d;
#       break;
#        }

#    location ~* \.(html|htm|txt)$ {
#       #add_header Pragma public;
#       add_header Cache-Control "public, must-revalidate, proxy-revalidate";
#       access_log off;
#       expires 1d;
#       break;
#        }

    location ~* \.(eot|svg|ttf|woff|woff2)$ {
        #add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        expires 30d;
        break;
        }

Guess next step is SPDY/3.1 SSL http://centminmod.com/nginx_configure_https_ssl_spdy.html :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...