- Compatible XF Versions
- 2.0
- 2.1
- Additional Requirements
- Apache htaccess
This script is based on different htaccess rules posted on xenforo forums and my own editing.
Requirements:
This script assumes you have friendly urls enabled for Xenforo.
What it will do
"/viewforum.php?f=X" will redirect to "/forums/X/" and
"/viewtopic.php?t=X" will redirect to "/threads/X/" and
"/viewtopic.php?p=X" will redirect to "/posts/X/".
"/memberlist.php?mode=viewprofile&u=X" will redirect to "/members/X/".
If you have /threads/title.x/ type of urls for xenforo, there might a second redirect by xenforo itself where it would redirect from threads/x/ to threads/title.x/
Installation
Insert this in your .htaccess file preferably BEFORE or ABOVE Xenforo friendly url redirect ( RewriteRule ^.*$ index.php [NC,L])
Done. That's all there is to it
If your forum is installed at say /forums/ then add /forums/ before the redirect in above script for example /threads/%2/? will be /forums/threads/%2/?
Requirements:
This script assumes you have friendly urls enabled for Xenforo.
What it will do
"/viewforum.php?f=X" will redirect to "/forums/X/" and
"/viewtopic.php?t=X" will redirect to "/threads/X/" and
"/viewtopic.php?p=X" will redirect to "/posts/X/".
"/memberlist.php?mode=viewprofile&u=X" will redirect to "/members/X/".
If you have /threads/title.x/ type of urls for xenforo, there might a second redirect by xenforo itself where it would redirect from threads/x/ to threads/title.x/
Installation
Insert this in your .htaccess file preferably BEFORE or ABOVE Xenforo friendly url redirect ( RewriteRule ^.*$ index.php [NC,L])
Code:
RewriteCond %{QUERY_STRING} (^|&)t=([0-9]+)(&|$) [NC]
RewriteRule ^viewtopic\.php$ /threads/%2/? [L,R=301,NC]
RewriteCond %{QUERY_STRING} f=(\d+)$ [NC]
RewriteRule ^(viewforum\.php|viewtopic\.php)$ /forums/%1/? [L,R=301,NC]
RewriteCond %{QUERY_STRING} (^|&)p=([0-9]+)(&|$) [NC]
RewriteRule ^viewtopic\.php$ /posts/%2/? [L,R=301,NC]
RewriteCond %{QUERY_STRING} u=(\d+)$ [NC]
RewriteRule ^memberlist\.php$ /members/%1/? [L,R=301,NC]
Done. That's all there is to it
If your forum is installed at say /forums/ then add /forums/ before the redirect in above script for example /threads/%2/? will be /forums/threads/%2/?