XF 1.2 Redirect VBSEO to Xenforo (Nginx)

younes

Active member
hello guys
i want redirect my current VBSEO urls to Xenforo
VBSEO thread example:
http://www.domain.com/thread145257.html
VBSEO forums Example:
http://www.domain.com/forum299.html
i use this http://tools.geekpoint.net/xfseo/ to convert my VBSEO links
RewriteRule thread([\d]+)-([\d]+).html showthread.php?t=$1&page=$2 [NC,L]
RewriteRule thread([\d]+).html showthread.php?t=$1 [NC,L]
RewriteRule forum([\d]+)-([\d]+).html forumdisplay.php?f=$1&page=$2 [NC,L]
RewriteRule forum([\d]+).html forumdisplay.php?f=$1 [NC,L]

but it's not working :(
thanks
 
Code:
  location ~* ^/[0-9]+-[^\.]+\.html$ {
  rewrite /([0-9]+)-[^\.]+\.html$ /showthread.php?t=$1 permanent;
  }

  location ~* ^/forum[0-9]+-[^\.]+\.html$ {
  rewrite forum([0-9]+)-[^\.]+\.html$ /forumdisplay.php?f=$1 permanent;
  }

  location ~* ^/member[0-9]+\.html$ {
  rewrite member([0-9]+)\.html$ /member.php?u=$1 permanent;
  }

I need specific examples of old and new URLs. If those rules were working before then something probably changed with your nginx configuration and you need to check that.
Thank you Jake
yes rules works fine before. but after upgrade php to 7.0.2 all old links redirect to the domain index
this is my nginx.conf
Code:
server
{
  listen 188.165.237.75:80;
  server_name  domain.com ;
  return  301 https://www.domain.com$request_uri;
}


server
{
  listen 199.175.287.75:80;
  server_name  www.domain.com ;
  return 301 https://www.domain.com$request_uri;
  access_log /var/log/nginx/domains/domain.com.log;
  access_log /var/log/nginx/domains/domain.com.bytes bytes;
  error_log /var/log/nginx/domains/domain.com.error.log;
  root /home/user/domains/domain.com/public_html;
  index index.php index.html index.htm;
  include /usr/local/directadmin/data/users/user/nginx_php.conf;
  location / {
  try_files $uri /index.php?$uri&$args;
  location /internal_data/ {
  internal;
  allow 127.0.0.1;
  deny all;
  }
  location /library/ {
  internal;
  allow 127.0.0.1;
  deny all;
  }
}
  location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
  expires 30d;
  add_header Pragma public;
  add_header Cache-Control "public";
}
server
{
  listen 199.175.287.75:80:443 ssl;
  server_name domain.com www.domain.com ;
  access_log /var/log/nginx/domains/domain.com.log;
  access_log /var/log/nginx/domains/domain.com.bytes bytes;
  error_log /var/log/nginx/domains/domain.com.error.log;
  root /home/user/domains/domain.com/private_html;
  index index.php index.html index.htm;
  ssl on;
  ssl_certificate /usr/local/directadmin/data/users/user/domains/bundle.cer;
  ssl_certificate_key /usr/local/directadmin/data/users/user/domains/domain.com.key;
  ssl_session_cache  shared:SSL:10m;
  ssl_session_timeout 60m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers HIGH:!aNULL:!MD5;
  add_header Strict-Transport-Security "max-age=31536000; preload" always;
  ssl_prefer_server_ciphers on;
  include /usr/local/directadmin/data/users/user/nginx_php.conf;
  include /usr/local/directadmin/data/users/user/pagespeed.conf;
  location ~* ^/thread[0-9\-]+\.html$ {
  rewrite thread([0-9]+)-([0-9]+)\.html$ /showthread.php?t=$1&page=$2 permanent;
  rewrite thread([0-9]+)\.html$ /showthread.php?t=$1 permanent;
  }

  location ~* ^/forum[0-9]+\.html$ {
  rewrite forum([0-9]+)\.html$ /forumdisplay.php?f=$1 permanent;
}
  location ~* ^/[0-9]+-[^\.]+\.html$ {
  rewrite /([0-9]+)-[^\.]+\.html$ /showthread.php?t=$1 permanent;
  }

  location ~* ^/forum[0-9]+-[^\.]+\.html$ {
  rewrite forum([0-9]+)-[^\.]+\.html$ /forumdisplay.php?f=$1 permanent;
  }

  location ~* ^/member[0-9]+\.html$ {
  rewrite member([0-9]+)\.html$ /member.php?u=$1 permanent;
  }

location / {

  try_files $uri /index.php?$uri&$args;
  location /internal_data/ {
  internal;
  allow 127.0.0.1;
  deny all;
  }
  location /library/ {
  internal;
  allow 127.0.0.1;
  deny all;
  }
}
  location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
  expires 30d;
  add_header Pragma public;
  add_header Cache-Control "public";
}
}
specific examples of old links

Threads
https://www.domain.com/thread145257.html

Forums
https://www.domain.com/forum293-house.html
https://www.domain.com/forum293.html
Members:
https://www.domain.com/member13004.html
 
Last edited:
Thank you Jake
yes rules works fine before. but after upgrade php to 7.0.2 all old links redirect to the domain index
this is my nginx.conf
Code:
server
{
        listen 188.165.237.75:80;
        server_name  persian-music.org ;
        return       301 https://www.persian-music.org$request_uri;
}


server
{
        listen 188.165.237.75:80;
        server_name  www.persian-music.org ;
        return 301 https://www.persian-music.org$request_uri;
        access_log /var/log/nginx/domains/persian-music.org.log;
        access_log /var/log/nginx/domains/persian-music.org.bytes bytes;
        error_log /var/log/nginx/domains/persian-music.org.error.log;
        root /home/persianm/domains/persian-music.org/public_html;
        index index.php index.html index.htm;
        include /usr/local/directadmin/data/users/persianm/nginx_php.conf;
         location / {
         try_files $uri /index.php?$uri&$args;
         location /internal_data/ {
     internal;
     allow 127.0.0.1;
     deny all;
  }
  location /library/ {
     internal;
     allow 127.0.0.1;
     deny all;
  }
}
        location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}
server
{
        listen 188.165.237.75:443 ssl;
        server_name persian-music.org www.persian-music.org ;
        access_log /var/log/nginx/domains/persian-music.org.log;
        access_log /var/log/nginx/domains/persian-music.org.bytes bytes;
        error_log /var/log/nginx/domains/persian-music.org.error.log;
        root /home/persianm/domains/persian-music.org/private_html;
        index index.php index.html index.htm;
        ssl on;
        ssl_certificate /usr/local/directadmin/data/users/persianm/domains/bundle.cer;
        ssl_certificate_key /usr/local/directadmin/data/users/persianm/domains/persian-music.org.key;
        ssl_session_cache   shared:SSL:10m;
        ssl_session_timeout 60m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!MD5;
        add_header Strict-Transport-Security "max-age=31536000; preload" always;
        ssl_prefer_server_ciphers on;
        include /usr/local/directadmin/data/users/persianm/nginx_php.conf;
        include /usr/local/directadmin/data/users/persianm/pagespeed.conf;
        location ~* ^/thread[0-9\-]+\.html$ {
                rewrite thread([0-9]+)-([0-9]+)\.html$ /showthread.php?t=$1&page=$2 permanent;
                rewrite thread([0-9]+)\.html$ /showthread.php?t=$1 permanent;
        }

        location ~* ^/forum[0-9]+\.html$ {
                rewrite forum([0-9]+)\.html$ /forumdisplay.php?f=$1 permanent;
}
                location ~* ^/[0-9]+-[^\.]+\.html$ {
                rewrite /([0-9]+)-[^\.]+\.html$ /showthread.php?t=$1 permanent;
        }

        location ~* ^/forum[0-9]+-[^\.]+\.html$ {
                rewrite forum([0-9]+)-[^\.]+\.html$ /forumdisplay.php?f=$1 permanent;
        }

        location ~* ^/member[0-9]+\.html$ {
                rewrite member([0-9]+)\.html$ /member.php?u=$1 permanent;
        }

location / {

        try_files $uri /index.php?$uri&$args;
        location /internal_data/ {
     internal;
     allow 127.0.0.1;
     deny all;
  }
  location /library/ {
     internal;
     allow 127.0.0.1;
     deny all;
  }
}
        location ~* \.(?:ico|css|js|gif|jpe?g|png|woff)$ {
    expires 30d;
    add_header Pragma public;
    add_header Cache-Control "public";
}
}
specific examples of old links

Threads
https://www.persian-music.org/thread145257.html

Forums
https://www.persian-music.org/forum293-house.html
https://www.persian-music.org/forum293.html
Members:
https://www.persian-music.org/member13004.html

The nginx rules appear to be working. It's the PHP redirect scripts that are failing. This probably means you need to edit the 301config.php file and confirm the name of the import_log table. If this is pointing to an empty table (or one which doesn't contain the mappings for your import) then it will redirect to the index.

edit - the import_log table is usually named one of these:

archived_import_log
xf_import_log
 
The nginx rules appear to be working. It's the PHP redirect scripts that are failing. This probably means you need to edit the 301config.php file and confirm the name of the import_log table. If this is pointing to an empty table (or one which doesn't contain the mappings for your import) then it will redirect to the index.

edit - the import_log table is usually named one of these:

archived_import_log
xf_import_log

Thank you, I really appreciate it
now working fine (y)
 
Hello @Jake Bunce!

I need to figure out how to rewrite these. We were running vbseo, and the thread ID's are the same.

vBulletin Link: /general-discussion/38094-fred-meyer-department.html
XenForo Link: /threads/fred-meyer-department.38094/

Each of the vB links pointed to the subforum, and then to the thread. The XF links point to the /threads/ sub-directory.

I'd really appreciate your help :)
 
Hello @Jake Bunce!

I need to figure out how to rewrite these. We were running vbseo, and the thread ID's are the same.

vBulletin Link: /general-discussion/38094-fred-meyer-department.html
XenForo Link: /threads/fred-meyer-department.38094/

Each of the vB links pointed to the subforum, and then to the thread. The XF links point to the /threads/ sub-directory.

I'd really appreciate your help :)

Add these rules to the top of the .htaccess file in your web root:

Code:
RewriteEngine On

RewriteRule ^[^/]+/([0-9]+)-[^\./]+\.html$ /threads/$1/ [R=301,L]
 
Hmm, doesn't seem to be working. Here's my conf.

Code:
location /xenforo/ {
     index index.php index.html index.htm;
     try_files $uri $uri/ /xenforo/index.php?$uri&$args;
}

location ~* ^/[^/]+/[0-9]+-[^\./]+\.html$ {
     rewrite /([0-9]+)-[^\./]+\.html
     /xenforo/threads/$1/ last;
}
 
Hmm, doesn't seem to be working. Here's my conf.

Code:
location /xenforo/ {
     index index.php index.html index.htm;
     try_files $uri $uri/ /xenforo/index.php?$uri&$args;
}

location ~* ^/[^/]+/[0-9]+-[^\./]+\.html$ {
     rewrite /([0-9]+)-[^\./]+\.html
     /xenforo/threads/$1/ last;
}

It should work. Maybe there is another matching rule higher up. Also make sure the rule is in the right server block.
 
@Jake Bunce can you help me with this?

I have this in vbulletin:

threads links:
forum-name/threadid-thread-title.html
nodes links:
/forumid-forum-name

can I have some help to make them work on nginx? :oops:

Code:
        location ~* ^/[^/]+/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
/threads/$1/ last;
        }

That will take care of threads. This assumes vB was in the root and XF is in the root.
 
Code:
        location ~* ^/[^/]+/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
/threads/$1/ last;
        }

That will take care of threads. This assumes vB was in the root and XF is in the root.
in case they was not in the root?

Code:
        location ~* ^vbdir/[^/]+/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
xfdir/threads/$1/ last;
        }

is this correct?

for forum nodes instead:
Code:
        location ~* ^vbdir/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
xfdir/forums/$1/ last;
        }

is this correct?
 
in case they was not in the root?

Code:
        location ~* ^vbdir/[^/]+/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
xfdir/threads/$1/ last;
        }

is this correct?

for forum nodes instead:
Code:
        location ~* ^vbdir/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
xfdir/forums/$1/ last;
        }

is this correct?

Try this:

Code:
        location ~* ^/vbdir/[^/]+/[0-9]+-[^\./]+\.html$ {
                rewrite /([0-9]+)-[^\./]+\.html
/xfdir/threads/$1/ last;
        }

        location ~* ^/vbdir/[0-9]+-[^/]+/?$ {
                rewrite /([0-9]+)-[^/]+/?$
/xfdir/forums/$1/ last;
        }
 
Top Bottom