News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4

Started by sianbg, February 18, 2018, 09:28:35 AM

Previous topic - Next topic

sianbg

Hello. I'm trying to enable prettyUrls, but still dont work. My forum is in hxxp:site.com/forums/ [nonactive]

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 hxxp:site.com/ [nonactive]. Something like codeigniter. Anyone can help me to fix this ?


-Rock Lee-

What kind of mistake does it give you? You have activated the mod security?


Regards!

¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Aleksi "Lex" Kilpinen

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.
Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: