Join the community today
Become a Member

Joomla How to config Rewrite in Joomla 3

Discussion in 'Blogs & CMS usage' started by computer19852007, Jul 2, 2014.

  1. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    My Website Vistit used Joomla 3,

    How to Config mod Rewrite?

    @eva2000

    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    unfortunately never used Joomla 3 so i wouldn't know the specifics, but it's like any other web app and Centmin Mod. Just find a working Nginx example for your web app (Joomla 3) and weave in the settings into Centmin Mod vhost's template format. You can see examples at http://centminmod.com/nginx_configure.html

    particularly how i took IP.Board's example Nginx config and wove it into Centmin Mod Nginx format at http://centminmod.com/nginx_configure_ipboard.html

    or ownCloud example of taking the official config for Nginx at http://doc.owncloud.org/server/6.0/.../installation_source.html#nginx-configuration and weaving it into Centmin Mod Nginx format https://community.centminmod.com/resources/how-to-install-owncloud-on-centmin-mod-nginx.1/
     
    • Like Like x 1
  3. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    i have config same you help, it cannot run

    I have config this i my Site, it working, but it do not optimize. Please Help Me @eva2000

    Code:
    server {
        listen       80;
        server_name www.ctsc.vn;
        return       301 http://ctsc.vn$request_uri;
    }
    
    
    server {
      server_name ctsc.vn;
      server_name_in_redirect off;
    
    
    
    
    # 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/ctsc.vn/log/access.log combined buffer=32k;
      error_log /home/nginx/domains/ctsc.vn/log/error.log;
    
      root /home/nginx/domains/ctsc.vn/public;
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      #try_files         / /index.php;
      try_files $uri $uri/ /index.php?q=$request_uri;
    
    
      }
    
    
      #pass php files to fastcgi
       location ~ \.php$
       {
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_index index.php;
                   include /usr/local/nginx/conf/fastcgi_params;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          #set expires to 0 to stop caching of php files
          expires 0;
       
       }
    
      location ~ ^/
       {
       #set expires to 30d to cache static files
       expires 30d;
       #file doesn't exist, will need to be sent to php
       if (!-e $request_filename)
       {
       rewrite ^/(.*)$ /index.php?q=$1 last;
         
       }
       }
    
    
            # caching of files
            location ~* \.(ico|pdf|flv)$ {
                    expires 1y;
            }
    
            location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
                    expires 14d;
            }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    

    Steps Check Error:

    Step 1: Click: http://ctsc.vn/gioi-thieu/y-kien-khach-hang.html
    (image in Right colum display the right)

    [​IMG]

    Step 2: Windows: Ctrl + F5 (Reload Web)

    Step 3: Error: Image not show
    [​IMG]

    -------
    Note:

    In Step 1: Image Drirectory URL: http://ctsc.vn/images/

    In Step 3: Image Drirectory URL: http://ctsc.vn/gioi-thieu/images/

    My Customer used mod K2 Content off Joomla 3
     
    Last edited: Jul 3, 2014
  4. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    only thing i see is you have duplicated the php location

    as this is not needed

    Code:
      #pass php files to fastcgi
       location ~ \.php$
       {
                   fastcgi_pass 127.0.0.1:9000;
                   fastcgi_index index.php;
                   include /usr/local/nginx/conf/fastcgi_params;
                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          #set expires to 0 to stop caching of php files
          expires 0;
     
       }
    as Centmin Mod takes care of that in the include file php.conf

    Code:
      include /usr/local/nginx/conf/php.conf;
    also these lines are duplicated

    Code:
            # caching of files
            location ~* \.(ico|pdf|flv)$ {
                    expires 1y;
            }
    
            location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
                    expires 14d;
            }
    as they are taken care of by staticfiles.conf include file

    Code:
      include /usr/local/nginx/conf/staticfiles.conf;
     
    • Like Like x 1
  5. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    Thanks, but it not working

    I have edit file conf, but it not Working
     
  6. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
  7. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    But a quick check at http://docs.joomla.org/Nginx#Configure_Nginx shows your vhost needs some changes IF the official doc config is working for Joomla 3

    Code:
    server {
        listen       80;
        server_name www.ctsc.vn;
        return       301 http://ctsc.vn$request_uri;
    }
    
    
    server {
      server_name ctsc.vn;
      server_name_in_redirect off;
    
    # 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/ctsc.vn/log/access.log combined buffer=32k;
      error_log /home/nginx/domains/ctsc.vn/log/error.log;
    
      root /home/nginx/domains/ctsc.vn/public;
    
      location / {
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
    try_files $uri $uri/ /index.php?$args;
      }
    
            # deny running scripts inside writable directories
            location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
                    return 403;
                    error_page 403 /403_error.html;
            }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
    }
    
     
    • Like Like x 1
  8. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    I have click Content http://ctsc.vn/gioi-thieu/lanh-dao.html => Server show Error:
    404 Not Found

     
  9. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34

    Attached Files:

  10. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    that is because you configured Joomla to server .html files via PHP and not Nginx as static files

    to work around that 404 remove or comment out html location in staticfiles.conf include at /usr/local/nginx/conf/staticfiles.conf and restart nginx

    FYI, serving .html via PHP reduces performance compared to via Nginx ;)
     
    • Like Like x 1
  11. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    I have delete it in staticfiles.conf, it wotking, but when Ctrl + F5, image have not show same: https://community.centminmod.com/threads/how-to-config-rewrite-in-joomla-3.659/#post-3005

     
  12. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    you probably have style image reference error so need to look at that

    Code:
    Request URL:http://ctsc.vn/gioi-thieu/images/banners/download.gif
    Request Method:GET
    Status Code:404 Not Found
    i assume the correct url would be

    Code:
    http://ctsc.vn/images/banners/download.gif
    
     
  13. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    looks like that is the case, incorrectly referenced html

    HTML:
    <img src="images/banners/download.gif" alt="Download Phần mềm Dự toán CT">
     
    • Like Like x 1
  14. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    if i used Apache, it not problem this error

     
  15. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    The problem is the relative reference to the current directory for your images as opposed to to root of your site

    incorrect

    Code:
    images/banners/download.gif
    correct

    Code:
    /images/banners/download.gif
    nothing to do with web server used
     
  16. computer19852007

    computer19852007 Member

    53
    5
    8
    Jun 25, 2014
    Ratings:
    +5
    Local Time:
    6:47 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    No...no

    ReWrite in Nginx working no right, because i have used Apache does not seen this error.

     
  17. eva2000

    eva2000 Administrator Staff Member

    30,902
    6,908
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,404
    Local Time:
    9:47 AM
    Nginx 1.13.x
    MariaDB 5.5
    then i'm at a loss as i am fairly sure that is your problem..

    something for you to investigate ;)