XenForo Redirects for vBulletin

XenForo Redirects for vBulletin 1.1.9

No permission to download
XF has committed an SEO sin with this script. If a thread, member profile or post doesn't exist they redirect to the homepage. This is really really horrible. Especially if you removed a lot of spam. Guess what, once you install this, all those spam links are now redirecting to your homepage.

if (!$target)
{
$target = $router->buildLink('canonical:index');
}
 
I'm getting 404 error

This is what in nginx vhost file location /
NGINX:
  location / {
  index index.php index.html index.htm;
  try_files $uri $uri/ /index.php?$uri&$args;
  include /usr/local/nginx/conf/503include-only.conf;

# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;

  # Enables directory listings when index file not found
  #autoindex  on;

  # Shows file listing times as local time
  #autoindex_localtime on;

  # Wordpress Permalinks example
  #try_files $uri $uri/ /index.php?q=$uri&$args;

  }

  include /usr/local/nginx/conf/pre-staticfiles-local-stage.conf;
  include /usr/local/nginx/conf/pre-staticfiles-global.conf;
  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;

  include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
  include /usr/local/nginx/conf/vts_server.conf;
  auth_basic "Private";
  auth_basic_user_file /usr/local/nginx/conf/conf.d/stage.HtPasswd;
  location /install/data/ {
  internal;
  }

  location /install/templates/ {
  internal;
  }

  location /internal_data/ {
  internal;
  }

  location /library/ {
  internal;
  }


  location /src/ {
  internal;
  }

No errors in admin panel server errors log
Imported from vb 3.8
nginx version: nginx/1.17.9 (100420-175959-centos7-3cb25c3)
PHP 7.3.16

old urls are like site.com/forum/showthread.php?t=14494561940

I had the previous vbulleting installed in /forum/
And xenforo is in the document root directory.

Anyone can spot the issue?
I just installed official add-on and then config the log table in admin options. nothing else.
Do I have to set nginx configurations too? I have installed xenforo into the default public directory.
But neither site.com/forum/showthread.php?t=14494561940 or site.com/showthread.php?t=14494561940 urls aren't redirecting.

on nginx if forum not in root directory change code
try_files $uri $uri/ /index.php?$uri&$args;
to
try_files $uri $uri/ /forum/index.php?$uri&$args;
 
Any help on converting the htaccess to nginx rewrites?

<IfModule mod_rewrite.c>
RewriteEngine On

# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# of the rewrite to reflect the path to your XenForo installation.
#RewriteBase /xenforo

# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>

add this

location / { try_files $uri $uri/ /index.php?$uri&$args ; } location ~ /(internal_data|library) { internal; }
 
Does anyone know if these redirect scripts can be modified, better yet by the Xenforo crew, to incorporate PhotoPost redirects. I retained the content IDs when imported my VBulletin 3.8 and photopost databases so it seems to me to be an easy add on. When I test it manually I just need to re-use the photo id in the original showphoto.php file (photopost) to get the new XFMG url.
ie:
1) http://originalwebsite.com/showphoto.php?photo=119445&title=2461&cat=6468,
2) Just take the content ID for photo (119445) and add it after media in the new URL: https://newwebsite.com/index.php?media/119445
3) Then seems to automatically redirect to https://newwebsite.com/index.php?media/2461.119445/ and the redirect is done.

Originally I just tried to do this with Apache redirect rules, but unfortunately these scripts here prevented it from working properly.

While not a priority for me, categories works the same way with showgallery.php?cat=504. Just remap cat=504 to index.php?media/categories/504/.

To me it seems like most of the logic is already there and the updates would be minor, but perhaps I'm not seeing something preventing this from being enhanced.

PS, I know there are a few other photopost pages, but if they get redirected with the same info to the above to items, I would think most of these items would be resolved.
 
AFAIR in the docs of this addon are steps mentioned if you have your forum in different locations compared to the original one. Did not apply to me so I can't help there. But from the nginx side you should be fine, as your requests reach xenforo. Only the addon has to get the paths to the former forum right ....

HTH
-Markus
Welp, it was still about the Nginx. The instructions on the guide did not work and @Kier said to move to the previous redirection scripts.
Anyway, here is the part I was looking for.

NGINX:
location ~ ^/forum/.*$ {
        rewrite ^/forum/(.*$) /$1 permanent;
}

If creating a subfolder and copying index.php file into it doesn't work, you can try something like this. (It didn't work in my case, I'm still not sure why, but this nginx rewrite rule works)

You can add that part above this code:

NGINX:
  location ~ \.php$ {
      try_files $uri /index.php?$uri&$args;
      fastcgi_pass    127.0.0.1:9000;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include         fastcgi_params;
  }
Final code looks like this:
NGINX:
  location ~ ^/forum/.*$ {
        rewrite ^/forum/(.*$) /$1 permanent;
  }

  location ~ \.php$ {
      try_files $uri /index.php?$uri&$args;
      fastcgi_pass    127.0.0.1:9000;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include         fastcgi_params;
  }
 
Last edited:
@Chris D seems like there are some links which don't work correctly. For example:

Code:
showthread.php?s=&threadid=12345

doesn't work, but the following does:

Code:
showthread.php?threadid=12345
 
I'm not exactly sure we'd expect to ever see the first version. Is that a real URL that happens in VB? I'm not sure I recall ever seeing it.

Parsing that out would essentially mean there's an empty URL parameter called s. It's valid, but it seems odd to me.
 
Yeah, it's definitely a valid URL as it's shown up in GSC, and has been reported to us as being broken - just not 100% certain where it came from. I'd imagine though any showthread.php URL containing the threadid GET parameter should work, but I haven't dug through how exactly this is handled so I'm assuming this is actually parsing the URL somehow rather than using the GET parameters specified? If you'd like the full URL I can send that to you in a DM.

Did a quick Google search for inurl:"showthread.php?s=&threadid=" and there are about 8.6k results so it's something that has shown up on other vBulletin installs as well

Screen Shot 2020-05-13 at 12.06.34 PM.webp

Worth noting that this is a XenForo 2 install that was previously on XenForo 1 for some period of time after being migrated from vBulletin, and from my understanding this URL worked with the redirect scripts available for XF1, but I'm assuming that's because it actually contained a showthread.php file and didn't go through XF's router at all so may not be a great comparison.
 
I forgot to ask if there were any other types of links similarly affected which was somewhat silly.

Nonetheless, that should fix showthread.php links.
 
I just applied the latest update, and it still seems to be an issue.

Problem link: showthread.php?s=53ec28189bacf442241ac1d9537926&t=115834
 
Last edited:
@Chris D .. Thanks .. looks great now
when you update it next time you may consider parsing query string instead of using regex because links like showthread.php?mode=hybrid&t=48429 doesn't work and I'm sure there are many more .
 
Not in the short-term but it may be necessary. It might have to be a more significant update because of the way the code works at the moment.
 
Top Bottom