Advertisement:

Author Topic: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4  (Read 1782 times)

Offline sianbg

  • Newbie
  • *
  • Posts: 2
Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
« 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
Code: [Select]
##
# 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 ?

Offline sianbg

  • Newbie
  • *
  • Posts: 2
Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
« Reply #1 on: February 23, 2018, 09:09:26 AM »
anyone can help ?

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 2,935
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
« Reply #2 on: February 23, 2018, 09:14:44 AM »
What kind of mistake does it give you? You have activated the mod security?


Regards!

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


Ayudame via PayPal

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,623
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: Mod rewrite for nginx + smf 2.0.15 + PrettyUrls1.1.4
« Reply #3 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.
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"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