Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: sianbg on February 18, 2018, 09:28:35 AM

Title: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
Post by: sianbg on February 18, 2018, 09:28:35 AM
Hello. I'm trying to enable prettyUrls, but still dont work. My forum is in site.com/forums/

I find some topics, but nothing help.

This is my config now

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen   80;
    listen   [::]:80;

    server_name dev.site.com;

    return 301 https://$server_name$request_uri;
}

server {
#listen 80;
# listen [::]:80;

# SSL configuration
#
listen 443;
# listen [::]:443 ssl default_server;
ssl on;
ssl_certificate         /ssl/s2.pem;
        ssl_certificate_key     /ssl/cs2.key;


access_log     /var/log/nginx/nginx.vhost.access.log;
        error_log      /var/log/nginx/nginx.vhost.error.log;

        location ~* \.(eot|ttf|woff|woff2)$ {
            add_header Access-Control-Allow-Origin *;
        }


root /home/site/dev/html;

# Add index.php to the list if you are using PHP
index  index.php;

server_name dev.site.com;

location / {
    #try_files $uri $uri/ @rewrite;
# rewrite (.*?)index\.php/*(.*) /$1$2 redirect;
#  if (!-e $request_filename){
#    rewrite ^(.*)$ /index.php/$1 break;
#  }

    auth_basic "Restricted Content";
    auth_basic_user_file /etc/nginx/.htpasswd;

}
    if ($host ~* ^www\.(.*))
    {
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }
    # canonicalize codeigniter url end points
    # if your default controller is something other than "welcome" you should change the following
    if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$)
    {
    rewrite ^(.*)$ / permanent;
    }
    # removes trailing "index" from all controllers
    if ($request_uri ~* index/?$)
    {
    rewrite ^/(.*)/index/?$ /$1 permanent;
    }
    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
    rewrite ^/(.+)/$ /$1 permanent;
    }
    # removes access to "system" folder, also allows a "System.php" controller
    #if ($request_uri ~* ^/system)
    #{
    #rewrite ^/(.*)$ /index.php?/$1 last;
    #break;
    #}
    # unless the request is for a valid file (image, js, css, etc.), send to bootstrap
    if (!-e $request_filename)
    {
    rewrite ^/(.*)$ /index.php?page=$1 last;
    break;
    }


# actions
rewrite ^/forums/(activate|admin|announce|ban|boardrecount|buddy|calendar|cleanperms)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(collapse|convertentities|convertutf8|coppa|deletemsg|detailedversion|display|dlattach)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(dumpdb|editpoll|editpoll2|featuresettings|featuresettings2|findmember|help|helpadmin)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(im|jsoption|jsmodify|lock|lockVoting|login|login2|logout)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(maintain|manageattachments|manageboards|managecalendar|managesearch|markasread|membergroups|mergetopics)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(mlist|modifycat|modifykarma|modlog|movetopic|movetopic2|news|notify)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(notifyboard|optimizetables|packageget|packages|permissions|pgdownload|pm|post)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(post2|postsettings|printpage|profile|profile2|quotefast|quickmod|quickmod2)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(recent|regcenter|register|register2|reminder|removetopic2|removeoldtopics2|removepoll)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(repairboards|reporttm|reports|requestmembers|search|search2|sendtopic|serversettings)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(serversettings2|smileys|smstats|spellcheck|splittopics|stats|sticky|theme)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(trackip|about:mozilla|about:unknown|unread|unreadreplies|viewErrorLog|viewmembers|viewprofile)/?$ "/forums/index.php?pretty;action=$1" last;
rewrite ^/forums/(verificationcode|vote|viewquery|who|\.xml)/?$ "/forums/index.php?pretty;action=$1" last;

# boards + topics
rewrite ^/forums/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ /forums/index.php?pretty%3Bboard=$1.0 last;
rewrite ^/forums/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/[0-9]?/?$ /forums/index.php?pretty%3Bboard=$1.$2 last;
rewrite ^/forums/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/[0-9]?/?$ /forums/index.php?pretty%3Bboard=$1%3Btopic=$2.0 last;
rewrite ^/forums/([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/[0-9]?/?$ /forums/index.php?pretty%3Bboard=$1%3Btopic=$2.$3 last;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}


}





I have diffrent rewrite for site.com/. Something like codeigniter. Anyone can help me to fix this ?
Title: Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
Post by: sianbg on February 23, 2018, 09:09:26 AM
anyone can help ?
Title: Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
Post by: -Rock Lee- on February 23, 2018, 09:14:44 AM
What kind of mistake does it give you? You have activated the mod security?


Regards!

Title: Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
Post by: Aleksi "Lex" Kilpinen on March 21, 2018, 05:50:01 AM
Mod related questions are usually best handled in the mod's own support topic.
However, if you let us know what errors you are getting, we might be able to help you better.