• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question URL rewriting not working with nginx

Oldiesmann

Basic Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
Plesk Obsidian 18.0.67 Update #3
The forum software I use has an addon that rewrites URLs, and will automatically generate the appropriate nginx rules as well as writing a .htaccess file. However, when I paste the rules into the "additional directives for nginx" thing and save it, I still get 404 errors for everything when using nginx alone. I've tried restarting nginx but that doesn't change anything. Right now I'm doing this on a test site to avoid breaking anything important, but I'd like to have this work if possible.
 
What forum software are you using and want is the rules you're using?

Also is proxy mode enabled? If proxy mode is enabled you're basically using Apache which would also depend if how you have PHP configured (FPM application served by nginx, FPM application served by Apache, or FastCGI served by Apache) so double check how those are configured as well.
 
It's SMF and these are the rules the addon generates. The mod works fine when proxy mode is enabled regardless of the PHP configuration since it doesn't rewrite URLs for static files. This only happens when proxy mode is disabled and PHP is served by nginx.

Code:
# Rules for: profiles
rewrite ^profile/([^/]+)/?$ "/index.php?pretty;action=profile;user=$1" last;

# Rules for: boards
rewrite ^([-_!~*'()$a-zA-Z0-9]+)/?$ "/index.php?pretty&board=$1.0" last;
rewrite ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ "/index.php?pretty&board=$1.$2" last;

# Rules for: topics
rewrite ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ "/index.php?pretty&board=$1&topic=$2.0" last;
rewrite ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ "/index.php?pretty&board=$1&topic=$2.$3" last;

# Rules for: actions
rewrite ^(agreement|acceptagreement|activate|admin|announce|attachapprove|buddy|calendar)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(clock|coppa|credits|deletemsg|dlattach|editpoll|editpoll2|findmember)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(groups|help|helpadmin|jsmodify|jsoption|likes|lock|lockvoting)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(login|login2|logintfa|logout|markasread|mergetopics|mlist|moderate)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(modifycat|movetopic|movetopic2|notifyannouncements|notifyboard|notifytopic|pm|post)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(post2|printpage|profile|quotefast|quickmod|quickmod2|recent|reminder)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(removepoll|removetopic2|reporttm|requestmembers|restoretopic|search|search2|sendactivation)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(signup|signup2|smstats|suggest|splittopics|stats|sticky|theme)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(trackip|about:unknown|unread|unreadreplies|uploadAttach|verificationcode|viewprofile|vote)/?$ "/index.php?pretty&action=$1" last;
rewrite ^(viewquery|viewsmfile|who|\.xml|xmlhttp|forum)/?$ "/index.php?pretty&action=$1" last;
 
So I did a few tests, I was able to somewhat work but other things gets broken and when I checked the admin log in SMF it shows there are some undefined array so I'm thinking this is more of whatever that prettyurl plugin is trying to do is broken.

The rules that kinda worked you can find in the first post of pretty urls + nginx - SOLVED

My suggestion is to reach out to the developer of that pretty url addon to see what they say though.
 
Back
Top