So today I'm writing this tutorial because the knowledge I've found with setting up MyBB SEO Friendly URLs for nginx particularly VestaCP+Nginx was particularly challenging to do.
I've found the "easiest" way to do it in which you will never have to edit your possibly "huge" configuration files nginx.conf and snginx.conf. The trick is to use vestacp's template system. Now before you say but VestaCP didn't include templates for MyBB I'm aware and it's why I wrote my own. That being said all of the information is below so enjoy![Smile Smile]()
System Requirements:
Any system that supports VestaCP will work with tutorial. I also expect that you are running VestaCP in "nginx+php-fpm" mode. I personally for the purposes of making this tutorial tested everything on an AWS EC2 t2.micro instance and didn't include the email packages nor any of the other crap such as DNS and iptables since my hosting provider provides me with a firewall plus a managed dns service. Evaluate your use case and configure accordingly whether that be running your own dns server or using a managed service like AWS Route53 or CloudFlare or something your hosting provider provides (there are so many options).
How to Setup:
Setting up the MyBB Template into VestaCP is quite simple.
Step 1- Include the follow files in this URL: "/usr/local/vesta/data/templates/web/nginx/php-fpm"
MyBB.tpl
MyBB.stpl
Step 2- Go into VestaCP and select the template mybb
![[Image: 1467868472_0.88673600.png]]()
(reference the above photo)
Step 3- Finally to ensure open your MyBB Admin Panel and enable search engine friendly URLS and everything should be good.
If you have any questions feel free to ask below and I'm open to feedback in improving the layout of this template. It's almost 1:30AM here and I'm trying to complete the tutorial while the information is fresh in my mind
I've found the "easiest" way to do it in which you will never have to edit your possibly "huge" configuration files nginx.conf and snginx.conf. The trick is to use vestacp's template system. Now before you say but VestaCP didn't include templates for MyBB I'm aware and it's why I wrote my own. That being said all of the information is below so enjoy

System Requirements:
Any system that supports VestaCP will work with tutorial. I also expect that you are running VestaCP in "nginx+php-fpm" mode. I personally for the purposes of making this tutorial tested everything on an AWS EC2 t2.micro instance and didn't include the email packages nor any of the other crap such as DNS and iptables since my hosting provider provides me with a firewall plus a managed dns service. Evaluate your use case and configure accordingly whether that be running your own dns server or using a managed service like AWS Route53 or CloudFlare or something your hosting provider provides (there are so many options).
How to Setup:
Setting up the MyBB Template into VestaCP is quite simple.
Step 1- Include the follow files in this URL: "/usr/local/vesta/data/templates/web/nginx/php-fpm"
MyBB.tpl
Code:
server {
listen %ip%:%web_port%;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
location / {
rewrite ^/forum-([0-9]+).html$ /forumdisplay.php?fid=$1;
rewrite ^/forum-([0-9]+)-page-([0-9]+).html$ /forumdisplay.php?fid=$1&page=$2;
rewrite ^/thread-([0-9]+).html$ /showthread.php?tid=$1;
rewrite ^/thread-([0-9]+)-page-([0-9]+).html$ /showthread.php?tid=$1&page=$2;
rewrite ^/thread-([0-9]+)-lastpost.html$ /showthread.php?tid=$1&action=lastpost;
rewrite ^/thread-([0-9]+)-nextnewest.html$ /showthread.php?tid=$1&action=nextnewest;
rewrite ^/thread-([0-9]+)-nextoldest.html$ /showthread.php?tid=$1&action=nextoldest;
rewrite ^/thread-([0-9]+)-newpost.html$ /showthread.php?tid=$1&action=newpost;
rewrite ^/thread-([0-9]+)-post-([0-9]+).html$ /showthread.php?tid=$1&pid=$2;
rewrite ^/post-([0-9]+).html$ /showthread.php?pid=$1;
rewrite ^/announcement-([0-9]+).html$ /announcements.php?aid=$1;
rewrite ^/user-([0-9]+).html$ /member.php?action=profile&uid=$1;
rewrite ^/calendar-([0-9]+).html$ /calendar.php?calendar=$1;
rewrite ^/calendar-([0-9]+)-year-([0-9]+).html$ /calendar.php?action=yearview&calendar=$1&year=$2;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+).html$ /calendar.php?calendar=$1&year=$2&month=$3;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+).html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+).html$ /calendar.php?action=weekview&calendar=$1&week=$2;
rewrite ^/event-([0-9]+).html$ /calendar.php?action=event&eid=$1;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass %backend_lsnr%;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include %home%/%user%/conf/web/nginx.%domain%.conf*;
}
MyBB.stpl
Code:
server {
listen %ip%:%web_ssl_port%;
server_name %domain_idn% %alias_idn%;
root %sdocroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
ssl on;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
location / {
rewrite ^/forum-([0-9]+).html$ /forumdisplay.php?fid=$1;
rewrite ^/forum-([0-9]+)-page-([0-9]+).html$ /forumdisplay.php?fid=$1&page=$2;
rewrite ^/thread-([0-9]+).html$ /showthread.php?tid=$1;
rewrite ^/thread-([0-9]+)-page-([0-9]+).html$ /showthread.php?tid=$1&page=$2;
rewrite ^/thread-([0-9]+)-lastpost.html$ /showthread.php?tid=$1&action=lastpost;
rewrite ^/thread-([0-9]+)-nextnewest.html$ /showthread.php?tid=$1&action=nextnewest;
rewrite ^/thread-([0-9]+)-nextoldest.html$ /showthread.php?tid=$1&action=nextoldest;
rewrite ^/thread-([0-9]+)-newpost.html$ /showthread.php?tid=$1&action=newpost;
rewrite ^/thread-([0-9]+)-post-([0-9]+).html$ /showthread.php?tid=$1&pid=$2;
rewrite ^/post-([0-9]+).html$ /showthread.php?pid=$1;
rewrite ^/announcement-([0-9]+).html$ /announcements.php?aid=$1;
rewrite ^/user-([0-9]+).html$ /member.php?action=profile&uid=$1;
rewrite ^/calendar-([0-9]+).html$ /calendar.php?calendar=$1;
rewrite ^/calendar-([0-9]+)-year-([0-9]+).html$ /calendar.php?action=yearview&calendar=$1&year=$2;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+).html$ /calendar.php?calendar=$1&year=$2&month=$3;
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+).html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4;
rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+).html$ /calendar.php?action=weekview&calendar=$1&week=$2;
rewrite ^/event-([0-9]+).html$ /calendar.php?action=event&eid=$1;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass %backend_lsnr%;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include %home%/%user%/conf/web/snginx.%domain%.conf*;
}
![[Image: 1467868472_0.88673600.png]](http://cdn.envyforums.net/share/1467868472_0.88673600.png)
(reference the above photo)
Step 3- Finally to ensure open your MyBB Admin Panel and enable search engine friendly URLS and everything should be good.
If you have any questions feel free to ask below and I'm open to feedback in improving the layout of this template. It's almost 1:30AM here and I'm trying to complete the tutorial while the information is fresh in my mind
